I have an editor script that instantiates a prefab when a GUI button is pressed. What I want is for this new prefab to be the selected object in the scene view. Here is my code:
var newLink = EditorUtility.InstantiatePrefab(NodePrefab) as GameObject;
newLink.transform.position = target.transform.position;
//Change selection to newLink here
Selection isn’t read-only, you just weren’t using a valid value for Selection.transform. That property is of type Transform[ ], not Transform. You may need to use activeTransform or gameObjects instead of transforms, too, to get the right effect.
Selection.transforms/Selection.gameObjects is read only. Selection.activeGameObject works, but there doesn’t seem to be any way to select multiple objects at once.
Thanks, I was working along these lines myself and didn’t realize I could just take the array I had casted and place it into Selection.objects.
Very useful indeed.