- Home /
Force select object in hierarchy via editor script?
Can you force an object as selected in the hierarchy editor view via an editor script?
I have an editor window script that collects some objects to give general warnings. I'd like to be able to force them as the selected objects in the hierarchy view for quick reference. Is that possible?
Answer by Julien-Lynge · Jan 26, 2013 at 11:27 PM
Yep, you certainly can. If I remember correctly, it's all in the Selection class:
http://docs.unity3d.com/Documentation/ScriptReference/Selection.html
Yeah I had been looking at that doc but wasn't sure how it would take my reference to and add it to that list of selections.
Do you just assign a new array of GameObjects to the Selection.gameObjects?
Even easier - you can just assign to Selection.activeGameObject. It's not read-only.
Hello, I don't expect you'll be able to reply since how old this post is, but please do if you can. I was fiddling around with the Selection class to to try and multi-selection some objects in the scene hierarchy -similar to how you would by holding down Ctrl+Clicking on the objects to select. Though i've had no luck. Any ideas on how to do it?