- Home /
How do I select a prefab that was just instantiated from an editor window?
Hi Unity,
I'm building out an Editor Window that will place prefabs on the Scene View. I'm trying to figure out how to : a) automatically select that newly created prefab in the Scene view so that the Manipulator is active for it. b) automatically focus on that item and shuttle the scene camera to it so that it's centered on the screen.
I have look on the forums but just can't seem to find an answer.
Thanks,
Answer by JohnRossitter · Mar 17, 2014 at 07:07 PM
I hate to be that guy that answers his own question, but I did find this article which has a static c# class which will move the scene view camera: http://www.olivereberlei.com/517/wrestling-with-the-editor-camera-in-unity/.
And selecting a newly added prefab from code is as easy as : Selection.ActiveObject = foo;
If you want the same focusing functionality the scene view gives when you press F, then you could get a reference to the scene view window, and send it a keydown F event. See how to send events and get references to windows.