Problem declaring List variable in JS

Quick question, I see a lot of people on the forums using lists in Javascript. Everytime I try to declare one to use, I get an error on my console saying that “List” is an unknown identifier. Any ideas why this is?

Example declaration:

var targetList=new List();

I’ve tried various other syntax from the forums and none of them work.


You have to use this to use List :

import System.Collections.Generic;

this is how to typecast a list of gameObjects :

var inRangeList : List. < GameObject > ;

this is how to declare a list of gameObjects :

inRangeList = new List. < GameObject > ();

Here is a really useful page on arrays and lists (for lists, scroll down to Generic List) :

I also get an error in unityscript try this

var mylist = new System.Collections.Generic.List.<GameObject>();