- Home /
Question by
Ilya · Apr 10, 2011 at 12:24 AM ·
arraystypecasting
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.
Comment
Best Answer
Answer by Eric5h5 · Apr 10, 2011 at 02:08 AM
Don't use Array. Use built-in arrays (GameObject[], etc.), or Lists (List., etc.).
Answer by Ilya · Apr 10, 2011 at 01:05 PM
What I needed is:
Selection.objects = ( new Array (target.transform.gameObject) ).ToBuiltin(GameObject);
Answer by DaveA · Apr 10, 2011 at 01:49 AM
Maybe you can use this: http://unity3d.com/support/documentation/ScriptReference/EditorGUIUtility.PingObject.html
Your answer
Follow this Question
Related Questions
Type casting error while instantiating. 1 Answer
Dynamic array length problem.Why my code generate error? 1 Answer
Typecast a Generic List in UnityScript 1 Answer
Dynamic multi-dimensional array in C#? 2 Answers
Naming array elements in editor 3 Answers