- Home /
The question is answered, right answer was accepted
It is not possible to invoke an expression of type 'System.Collections.Generic.List.
Hi all, im having a problem with this code that tells me this: It is not possible to invoke an expression of type 'System.Collections.Generic.List.', ihave a class called itemHandler that i call with system.collections.generic, (or something like that, im new with this) also im in unity 5 can someone help me? this is the code thx =)
import System.Collections.Generic;
var equipList : List. = new List.();
var update : boolean = false;
private var itemIcon : Texture2D;
function Start () {
//Equipment [0 = Head, 1 = Chest, 2 = Legs, 3 = RightHands, 4 = LeftHand,etc ]
//head
equipList.Add(new ItemHandler(0, itemIcon, "", "", false, ItemType.Head));
//chest
equipList.Add(new ItemHandler(0, itemIcon, "", "", false, ItemType.Chest));
//Legs
equipList.Add(new ItemHandler(0, itemIcon, "", "", false, ItemType.Legs));
//RightHand
equipList.Add(new ItemHandler(0, itemIcon, "", "", false, ItemType.RightHand));
//LeftHand
equipList.Add(new ItemHandler(0, itemIcon, "", "", false, ItemType.LeftHand));
}
function Update () {
if (!equipList(0).equipped && update){
equipList(0)=(new ItemHandler(0, itemIcon, "", "", false, ItemType.Head));
update = false;
}
}
Answer by meat5000 · Mar 14, 2015 at 09:54 PM
Try declaring your list like this
var equipList : List.<Type>;
where I presume your Type is ItemHandler
Edit : Access your elements with [i] instead of (i).
thank you for the answer but that dont work u.u you know another way to do that? and i see the code again in this page and see that this say: var equipList : List. = new List.();
, but actually is: var equipmentList : List.< ItemHandler > = new List.< ItemHandler >();
When I tried that line with your code the stated error went away then I got all the regular errors associated with the rest of the references being missing in my project.
Access your elements with [i] ins$$anonymous$$d of (i).