- Home /
Concat() for Lists
I've got a list called GhostObjects:
private var GhostObjects : List.<GameObject> = List.<GameObject>();
There are either two types of ghosts in the scene, big ones and small ones:
function Start () {
GhostObjects = GameObject.FindGameObjectsWithTag("BigGhost").Concat(GameObject.FindGameObjectsWithTag("SmallGhost")).ToArray();
}
The error I'm getting, is that it cannot convert:
UnityEngine.GameObject[] to System.Collections.Generic.List<UnityEngine.GameObject>
How do I resolve this error?
Thanks!
Comment
Best Answer
Answer by Lemo76 · Mar 07, 2015 at 05:58 AM
Solved it!
All I had to was replace .ToArray() into .ToList()!