Last active
May 23, 2016 06:20
-
-
Save paraself/2224a6d836246adc105b6eaf1c8856a1 to your computer and use it in GitHub Desktop.
Sync 2d Camera between scene view and game view. So whenever you pan your scene view by holding the middle mouse btn, the game view will always match its position to the scene view camera. However scene view's zoom in and out will not be taken into account. The ortho size of the game view camera will remain all the time. This is perfect for maki…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///Sync camera position between scene camera and the rendering camera | |
//Add [ExecuteInEditorMode] to your monobehaviour and add the following OnRenderObject method as well. | |
///... | |
[ExecuteInEditorMode] | |
//... | |
void OnRenderObject () { | |
cam = Camera.current; | |
if (cam!=null && cam.name == "SceneCamera") { | |
Vector3 pos = cam.transform.position; | |
Vector3 _pos = transform.position; | |
transform.position = new Vector3 (pos.x,pos.y,_pos.z); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment