|
Hello, I'd like to write an editor script that forces the scene view camera (in the editor) to follow an object as it moves while the game is playing (Like the player). How can I get access to the editor camera so that I can do this?
(comments are locked)
|
|
This thread should give you the information you need: http://forum.unity3d.com/viewtopic.php?t=33679 Basically, you can get the scene camera with I'm not sure how much you can modify the Scene camera, either... I've heard mixed reports in the past. I've heard you can't really change how the camera behaves very much, but I've also seen some editor scripts that (claim to) modify it, so if something isn't working for you, it might just not be possible. Thanks. If it's null while the scene view does not have focus then this won't work for me. I need it to follow while I play the game. However, you did answer my question!
May 18 '10 at 09:18 PM
Robert 1
Then I don't know if what you want is possible... you could wait to see if someone else responds here, or ask on the forums if you need it that badly. :P
May 18 '10 at 09:28 PM
qJake
Bob, perhaps you could save what camera you are referencing when the scene does have focus, and then use that reference later? I'm atm trying to do something similar myself, don't know if it'll work. Think of it like this: I open my custom editor window. Editor window keeps trying to assign a camera - if null, retry. I click on the scene view. Camera get's assigned. I click outside, but the reference is kept.
May 05 '11 at 01:43 PM
Joshua
(comments are locked)
|
|
I had the same issue and wrote a script that follows the specified target transform. It even works for multiple SceneViews. It's on Unity3D's wiki now: http://wiki.unity3d.com/index.php/SceneViewCameraFollower Hope it helps.
(comments are locked)
|
|
There is another way to accomplish this using the (undocumented) UnityEngine.SceneView interface. While there is no way to directly set the current scene view camera's transform, there's a handy AlignViewToObject call (identical to the GameObject menu item). Here's some C# trickery: I use this general strategy in a number of ways to make scene navigation less painful for myself, but you can probably see how it might be altered to suit your needs (e.g. since you are updating the camera every frame, it probably makes sense to keep a persistent dummy object around for alignment, rather than creating and destroying one each time). Hope this helps!
(comments are locked)
|
