private ArrayList ListA = new ArrayList();
ListA.Add(Instantiate(PrefabA,transform.position, Quaternion.identity) as GameObject);
Debug.Log(ListA[0]);
I wonder why the console give me a “null” ~~ Thanks
private ArrayList ListA = new ArrayList();
ListA.Add(Instantiate(PrefabA,transform.position, Quaternion.identity) as GameObject);
Debug.Log(ListA[0]);
I wonder why the console give me a “null” ~~ Thanks
Try this :
ListA.Add((GameObject)Instantiate(PrefabA,transform.position, Quaternion.identity));
You should obtain an nice exception :-).
The ‘as’ operator return null if the cast fails. So I guess that your are not instantiating a game object…
thanks BigBullee & aldonaletto both of you are right