- Home /
Question by
GeekURLant · Feb 07, 2011 at 04:58 PM ·
variableinspector
Script with variable number of variables ?
Hi,
I'd like to create a script which take GameObject in parameters in the inspector. But I'd like to add a GameObject variable by pressing a button in the inspector.
Can it be done ?
Regards, Sladix.
Comment
Best Answer
Answer by Molix · Feb 07, 2011 at 05:14 PM
Just add an array of GameObjects as a member of your script, e.g.
public GameObject[] myGameObjects;
The default array inspector will let you add them, but to have a special button, you'd want to make a custom inspector.
Thanks, how could I sort theses gameObject (by transform.position.x or by component), do I have to do this on my own ?
I'd make a compare function and pass that to Array.Sort() (not a Unity function).