- Home /
how would I make an array of different scripts
how would I make an array of available scripts. I have 3 scripts script1.js, script2.js, script3.js
I want to do something like this myscripts=new List.
Answer by Alec-Slayden · Feb 29, 2012 at 09:58 AM
Surprisingly (to me)
This will work for javascript scripts:
var MyScripts : Array = new Array();
function Start () { MyScripts.Add(Thing1); MyScripts.Add(Thing2);
gameObject.AddComponent(MyScripts[1].ToString());
}
Assuming, of course, you have javascripts named Thing1 and Thing2.
I added / editted this but it won't update to me. It should say "Assu$$anonymous$$g, of course, you have javascripts named Thing1 and Thing2"
Your answer
Follow this Question
Related Questions
Accessing an Array in another function 1 Answer
.getComponent() creates an Instance? 1 Answer
Load Objects from a specific directory into a list? 0 Answers
Array of Objects of a Class 1 Answer
Create array of scripts 1 Answer