convert built in array to javascript error
Hey guys. I'm trying to convert a built in array to a javascript array, but I keep getting this error message: ArgumentNullException: Argument cannot be null. Parameter name: collection UnityScript.Lang.Array.AddRange (IEnumerable collection) UnityScript.Lang.Array..ctor (IEnumerable collection)
Here is my code:
var st:GameObject[];
st=GameObject.FindGameObjectsWithTag("st");
Debug.Log(st[0]);
Debug.Log(st[1]);
Debug.Log(st[2]);
Debug.Log(st[3]);
var stp= new Array(st);
Thanks for the help:)
Answer by Vice_Versa · Sep 04, 2015 at 09:02 PM
it would help if you posted what line the error occurred on, but from the looks of it, the last line is whats causing this. From the looks of things, im assuming that your FindGameObjectsWithTag("st") is not finding these GameObjects. Are you sure you tagged them correctly?
Thanks for the help:) Yes the conversion between array types is causing it, the debugs are just to check that the first line is totally normal. I figured you simply have to enclose it in a function (I use start), which often fixes many problems I've come across:p Cheers!
Your answer
Follow this Question
Related Questions
A certain string is causing trouble! (Javascript) 0 Answers
Help with variables 1 Answer
Javascript Animation Playing Error 1 Answer
One Shot Sound After Countdown JS 1 Answer