Hi, everyone. I am attempting to make a mass component adder, but when I input the number of gameobjects and press update, it doesn't make the object fields. I know why, the array is at a length of zero, so how do I resize it? If necessary, here is my code so far. Any help would be appreciated =]
class MassComponentAdder extends EditorWindow {
public var objs : GameObject[];
public var Int : int;
public var script : MonoBehaviour;
@MenuItem("CUSTOM/MassComponentAdder")
static function Init() {
var window = GetWindow(MassComponentAdder);
window.Show();
}
function OnGUI() {
Int = EditorGUI.IntField(Rect(3, 3, position.width-6, 20), "Number of GameObjects: ", Int);
if(GUI.Button(Rect(3, 25, position.width/2-6, 25), "Update"))
{
for(i = 0; i < Int; i++)
{
objs _= EditorGUI.ObjectField(Rect(3, 25+(i*25), position.width/2-6, 25), "Object "+i, objs*, GameObject);*_
_*}*_
_*}*_
_*if(GUI.Button(Rect(position.width/2, 25, position.width/2 - 6, 20), "Add Rigidbody"))*_
_*{*_
_*for(k = 0; k < Int; k++)*_
_*{*_
_*if(objs[k] != null)*_
_*{*_
_*objs[k].AddComponent(Rigidbody);*_
_*}*_
_*}*_
_*}*_
_*if(GUI.Button(Rect(position.width/2, 45, position.width/2 - 6, 20), "Add Light"))*_
_*{*_
_*for(j = 0; j < Int; j++)*_
_*{*_
_*if(objs[j] != null)*_
_*{*_
_*objs[j].AddComponent(Light);*_
_*}*_
_*}*_
_*}*_
_*if(GUI.Button(Rect(position.width/2, 65, position.width/2 - 6, 20), "Add Camera"))*_
_*{*_
_*for(l = 0; l < Int; l++)*_
_*{*_
_*if(objs[l] != null)*_
_*{*_
_*objs[l].AddComponent(Camera);*_
_*}*_
_*}*_
_*}*_
_*}*_
_*}*_
_*```*_