can someone explain to me why this does not work?

if i put these lines of code in the script:

import System.Collections.Generic;
var boxColliderList : List.<Collider>=new List.<Collider>();

i get this error:

Unexpected Token: …

i wanted to start using lists instead of arrays but no luck… it seems that most simplest thing is not working, like declaring a list…i am using unityscript as you can see…

thanks!

Hello there!

Simply remove the dots you’ve placed between List and , they’re not supposed to be there.

but that should be syntax for unityscript? if i am not mistaken?

if i remove dots i get this error:
Unexpected Token: <.

Please don’t post on UnityAnswers and here, especially without a cross-link. :rage:

http://answers.unity3d.com/questions/44083/why-this-does-not-work-lists

i tried the things you suggested:

var boxColliderList : List.<Collider> = new List.<Collider>();
var boxColliderList = List.<Collider>();

still getting the “Unexpected Token : …” error

i was so desperate i even tried reinstalling NET (i do not know if this is related)

i do not know what to try any more…
can someone post the part of the code that works for somebody else (unityscript) so that i can try

Yeah, that’s why the link is there. You could have at least wrapped in in quotes.

i just restarted my computer as a desperate move… and it did not work :slight_smile:

i am using unity2.6 is that maybe a problem??

so apparently i cant use Lists in unityscript if i use Unity2.6

Not directly, no.

No, Unity uses Mono, not .NET.

–Eric

is there any other way to use lists in 2.6 (you said directly i cant)

Put this C# script in Standard Assets and call it ListX:

using UnityEngine;
using System.Collections.Generic;

public class ListX {
	public static List<Collider> ColliderList () {
		return new List<Collider>();
	}
}

Then in JS you can do this:

function Start () {
	var boxColliderList = new ListX.ColliderList();
	boxColliderList.Add (collider);
	Debug.Log (boxColliderList.Count + " " + typeof(boxColliderList));
}

If you need other kind of Lists you can add appropriate functions to ListX.

–Eric

nice, thanks!