Javascript how to fill an array?
Hi! I´ve got Problems in Unity with Arrays. I want to write a value into a position in an array. But it doesnt work. The Console outputs "null". Maybe you can help me!
function Start () {
}
function Update () {
}
var reihe1 : Array = new Array[5];
function OnGUI(){
if( GUILayout.Button("Reihe 1")){
PR1();
}
}
function PR1(){
if(reihe1[0]!=1 && reihe1[0]!=2){
GameObject.Find("muenzen_rot").GetComponent.<Animation>().Play("1_1");
reihe1[0]==1;
print(reihe1[0]);
}
if(reihe1[0]==1 && reihe1[0]==2){
GameObject.Find("rot12").GetComponent.<Animation>().Play("1_2");
reihe1[1]==1;
}
}
Comment
Answer by Jessespike · Dec 16, 2015 at 07:07 PM
"=" assigns values
"==" compares values
In the snippet. Values aren't being assigned, they are being compared.
reihe1[0]==1;
Should read:
reihe1[0]=1;
Your answer
Follow this Question
Related Questions
C# noob question (array realated) 1 Answer
Index out of range why? (possible bug) 1 Answer
I'm trying to shuffle an array's order 3 Answers
Parameter Name: Index 0 Answers
[SOLVED]How do I spawn GameObject[] in Transform[]? 2 Answers