- Home /
select object in scene view
I'd like to be able to script for selecting objects in the scene view, instead of the game view. Is this possible?
Could you please reword your answer - I'm not sure people know what you're asking...
So, when viewing my game level, I sometimes want to switch to scene view where I can get an overall look at my objects. It would be nice if, in scene view, I could select an object and have unity display additional information about the object. Not in the game view, but in the scene view.
You probably found the Selection editor class already. It's not totally clear from the docs whether its fields are readonly or can be used to control the selection procedurally. Have you tried?
http://unity3d.com/support/documentation/ScriptReference/Selection.html
Answer by vollchecker · Oct 06, 2015 at 11:25 AM
(one Selection) Selection.activeTransform = yourTransform; (more Selections) Selection.objects = yourObjects;
For example add this script to a gameObject in your Scene. using UnityEditor; using UnityEngine; using System.Collections;
[ExecuteInEditMode] public class TestClass : MonoBehaviour { public GameObject[] allGameObjects;
void Update()
{
allGameObjects = FindObjectsOfType<GameObject>();
// call Function
SelectOneGameObject();
//SelectAllGameObjects();
}
public void SelectOneGameObject()
{
Selection.activeTransform = allGameObjects[0].transform;
}
public void SelectAllGameObjects()
{
Selection.objects = allGameObjects;
}
}