- Home /
Modify SceneCamera's position in script?
I'm trying to create an editor script that can change the scene camera's position. In an OnSceneGUI call I do this :
if (Camera.current)
{
Debug.Log("Taking over camera " + Camera.current.name);
Debug.Log("Cam pos " + Camera.current.transform.position);
Camera.current.transform.position = Vector3.zero;
Debug.Log("Took over camera " + Camera.current.name);
Debug.Log("Cam pos " + Camera.current.transform.position);
}
When I do this, in the log i see this :
Taking over camera SceneCamera, Cam pos (11018.4, 6246.7, 7877.6), Took over camera SceneCamera, Cam pos (0.0, 0.0, 0.0)
however, this does not happen in the next frame, and the log in the next frame shows the exact same log lines (take camera position from X to 0). So it seems like this is getting overwritten somewhere along the line.
Is it possible to do something like this?
Did you ever figure out a workaround? I'm looking to set the SceneCamera's position and orientation to those of Camera.main when the player pauses the game in the editor.
Answer by Eric5h5 · Oct 14, 2010 at 02:27 PM
The scene camera is read-only as far as I know.
So scripts such as the F button (focus on active objects) are impossible to implement?
I've just posted a question related to the scene camera (http://answers.unity3d.com/questions/416008/problem-accessing-the-scene-camera.html).
How would you go about querying its transform information? In Unity 4 the "Camera.current" method always returns "null". Even when the game is launched while the scene view is active.
Since your question was asked about 3 years ago, I'm hoping things have changed a bit...
Your answer
Follow this Question
Related Questions
Unity Scene View's right-click + WASD doesn't look 3D anymore? 2 Answers
Changing master view move speed. 3 Answers
How can I make a custom 3d editor within the Unity editor? 1 Answer
'Locking' a scene cam in editor? 0 Answers
How do I take a high quality screen shot from my scene view camera? 5 Answers