x


Compiler errors?

I got this strange error and cant figure how to fix it?

using UnityEngine; using System.Collections; using System.Collections.Generic;

public class Loot : MonoBehaviour { public float lootwindowheight = 90; public float Buttonheight = 40; public float Buttonwidth = 40; private List _lootItems; private float OFF_SET = 10; private const int LOOT_WINDOW_ID = 0; private Rect _lootWindow = new Rect(0,0,0,0);

// Use this for initialization
void Start () {
   _lootItems = new List <Item>();

    Populate();
}

// Update is called once per frame
void Update () {

}


 void OnGUI() {
     _lootWindow = GUI.Window(LOOT_WINDOW_ID, new Rect(OFF_SET, Screen.height - (OFF_SET + lootwindowheight), Screen.width - (OFF_SET * 2), lootwindowheight), LootWindow, "Loot Window");
 }

 private void LootWindow(int id) {
     for(int cnt = 0; cnt < _lootItems.Count; cnt++) {
        GUI.Button(new Rect(Buttonwidth * cnt, 0, Buttonwidth, Buttonheight), cnt.ToString());
     }
 }

 private void Populate() {
     for(int cnt = 0; cnt < 25; cnt++)
     _lootItems.Add(new Items());
 }

}

more ▼

asked Jul 04 '11 at 07:01 AM

Keith18127389 gravatar image

Keith18127389
-194 11 12 14

what is the error and on which line is it reported?

Jul 04 '11 at 07:05 AM Dreamora

_lootItems = new List (Item)(); //Error is here

and it says Item could not be found?

Jul 04 '11 at 07:09 AM Keith18127389
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

Specifically, what is the error you're getting. Just copy and paste it. I'm inclined to believe that the error stems from the fact that you created an untyped private list and the tried to initialize it with type "item".

Always post your error if you're getting one, and always make sure your code is properly formatted before you post your question :)

Qato likes to format half of a code block and leave the rest all messed up.

more ▼

answered Jul 04 '11 at 08:02 AM

testure gravatar image

testure
4.2k 20 25 48

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

then there is no class called Item thats present in this or an earlier compile step.

See the advanced manual on compilation order to know whats being compiled first to ensure that this class here is not within that one. Should you mix C# and UnityScript it will also tell you what to keep in mind to have one of them use the other

more ▼

answered Jul 04 '11 at 07:14 AM

Dreamora gravatar image

Dreamora
3.3k 1 4 25

(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:

x4367
x2028
x41

asked: Jul 04 '11 at 07:01 AM

Seen: 673 times

Last Updated: Jul 04 '11 at 08:02 AM