Casting arrays in js

Hello, I want to make sure that only one objects is selected in the editor.

What's wrong with the following?

Selection.objects = new Array(target.transform.gameObject);

I get InvalidCastException.

3 Answers

3

Don't use Array. Use built-in arrays (GameObject[], etc.), or Lists (List., etc.).

Maybe you can use this: http://unity3d.com/support/documentation/ScriptReference/EditorGUIUtility.PingObject.html

What I needed is:

Selection.objects = ( new Array (target.transform.gameObject) ).ToBuiltin(GameObject);