- Home /
List problem?
I have a list for my characters to know how many enemies there are, but there is a problem. Unity says that List is an unknown identifier. I'm using javascript. Here is the code.
var targetList = new List.<GameObject>(GameObject.FindGameObjectsWithTag(targetString));
It's just whats necessary.
Thanks in advance!
Answer by Hoeloe · Sep 29, 2013 at 11:40 PM
In pretty much every programming language you'll encounter, List
is not the same thing as list
. Case matters. Try writing new List....
instead.
In that case, sounds like you've forgotten to import the generic collection library. $$anonymous$$ake sure the line: import System.Collections.Generic;
is at the top of your script file.
Just for the sake of clarity, that's not "importing the generic collection library", which seems to be a common misconception. Nothing is actually imported; List and other generic collections are part of mscorlib so they're always present no matter what. It's just using the System.Collections.Generic namespace so you don't have to write it out "System.Collections.Generic" every single time you reference List.
Answer by lancer · Sep 30, 2013 at 12:17 AM
Add
import System.Collections.Generic;
To the top of your script.
Your answer
Follow this Question
Related Questions
UnityScript for unique simpleJSON lists 0 Answers
An Array within array 2 Answers
A node in a childnode? 1 Answer
How can i store the Amount of an item i have in an inventory? 0 Answers
Getting C# to access a javascript global Array and Components 1 Answer