x


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?

more ▼

asked Oct 14 '10 at 02:02 PM

Noam gravatar image

Noam
282 24 24 33

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.

Feb 14 '11 at 11:44 PM colinf

Impossible as of now :(

Feb 16 '11 at 03:29 PM Noam
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

The scene camera is read-only as far as I know.

more ▼

answered Oct 14 '10 at 02:27 PM

Eric5h5 gravatar image

Eric5h5
80.3k 42 132 521

So scripts such as the F button (focus on active objects) are impossible to implement?

Oct 14 '10 at 03:24 PM Noam

Unfortunately yes, I think so.

Oct 14 '10 at 03:33 PM Eric5h5

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...

Mar 13 at 01:32 PM Seith
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3014
x1677
x720

asked: Oct 14 '10 at 02:02 PM

Seen: 1210 times

Last Updated: Mar 13 at 01:32 PM