- Home /
add GameObject in GameObject[] (js)
Help please need add GameObject in GameObject[]
I translated script from c# in js and this 2 functions not working and i don't know what need write here
var objs : GameObject[];
objs.Add(go);
and
var count : int = objs.Count;
i know can use objs.Length but if some object in objs = null - error
Answer by whydoidoit · Jul 04, 2012 at 06:59 AM
Make your variable a List and then it will work.
import System.Collections.Generic;
...
var objs = new List.<GameObject>();
Answer by Eric5h5 · Jul 04, 2012 at 07:45 AM
Technically you can use Array.Resize for built-in arrays if you want to make them bigger, but if you're doing that, you're usually better off with List.
Your answer

Follow this Question
Related Questions
Adds infinite # of components, using GameObject.AddComponent. 4 Answers
add waypoint to transform[] 2 Answers
`Inventory' does not contain a definition for `Add' 2 Answers
using Contains(gameObject) to find and destroy a gameObject from a list 2 Answers
Get GameObject from List based on attached script or assigned name 3 Answers