x


Unity 3.2 using System.Collections.Generic; error

hello

i have been following the tutorial of burgzerg arcade until i face with problem using List<> component

i m currently using unity 3.2

the code line gives error is " private List _lootItems; " and i already have "using System.Collections.Generic; " defined at top

compiler still gives error as "the type or namespace name 'Item' could not be found. Are u missing a using directive or an assembly reference"

in tutorial video of burgzerg script can be compiled with no error why am i getting this error since i use the exact same code

thanx in advance.

more ▼

asked Apr 04 '11 at 08:57 AM

seyyid gravatar image

seyyid
91 3 3 6

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

Do you have a class defined with the name "Item" in your project?

And I think your list declaration would have to look like this:

private List<Item> _lootItems;
more ▼

answered Apr 04 '11 at 09:07 AM

KeithK gravatar image

KeithK
862 2 3 13

Yeah, I would say that's the problem. You try to create a List<Item> but there is no Item class. Maybe you missed something in the tutorial? I never used a tutorial so i don't know the one you talk about ;)

Apr 04 '11 at 10:57 AM Bunny83

i m sorry i posted wrong script it was already as you typed private List _lootItems; but still error, in tutorial he doesnt have Item class but as you said he most probably has that Item class as public from other script and calling it in this script, thanx for reply i ll try to solve with ur answer:)

Apr 05 '11 at 12:38 AM seyyid
(comments are locked)
10|3000 characters needed characters left

i fixed it Item stands for a script he hase made and i heve it here

    using UnityEngine;


public class Item {
 private string _name;
 private int _value;
 private RarityTypes _rarity;
 private int _curDur;
 private int _maxDur;



 public Item (){
 _name = &quot;Need Name&quot;;
 _value = 0;
 _rarity = RarityTypes.Common; 
 _maxDur = 50; 
 _curDur = _maxDur; 
 }
 public Item(string name, int value, RarityTypes Rare,  int maxDur, int curDur){
 _name = name;
 _value = value;
 _rarity = Rare; 
 _maxDur = maxDur; 
 _curDur = curDur; 

 }



 public string Name {
 get{ return _name; }
 set {_name = value; }
 }
 public int Value {
 get { return _value; }
 set { _value = value;} 
 }
 public RarityTypes Rare{

 get {return _rarity; }
 set {_rarity = value;} 

 }
 public int MaxDuribility {
 get { return _maxDur;}
 set {_maxDur = value;} 
 }
 public int CurDuribility {
 get { return _curDur;}
 set {_curDur = value;} 
 }
}

public enum RarityTypes{
 Common,
 Uncommon,
 Rare

}
more ▼

answered Jul 05 '12 at 08:35 PM

xander5532 gravatar image

xander5532
1

(please learn to format your code by marking it and hitting the little 101010 button; I did it for you this time...)

Jul 05 '12 at 08:36 PM SisterKy
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x382
x41
x36
x8

asked: Apr 04 '11 at 08:57 AM

Seen: 2663 times

Last Updated: Jul 05 '12 at 08:36 PM