x


BurgZerg Arcade Inventory Error

Hi! Plz help, I have an Error: Assets/myGUI.cs(11,22): error CS0246: The type or namespace name `Item' could not be found. Are you missing a using directive or an assembly reference?

Here the script: using UnityEngine; using System.Collections; using System.Collections.Generic;

public class myGUI : MonoBehaviour { public float lootWindowHeight = 90;

public float buttonWidth = 40;
public float buttonHeight = 40;

private List<Item> _lootItems;
private float _offset = 10;
private const int LOOT_WINDOW_ID = 0;
private Rect _lootWindowRect = 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() {
    _lootWindowRect = GUI.Window(LOOT_WINDOW_ID, new Rect(_offset, Screen.height - (_offset + lootWindowHeight), Screen.width - (_offset * 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 Item());
}

}

more ▼

asked Jun 30 '12 at 01:29 PM

Krumplee14 gravatar image

Krumplee14
2 1 1

The problem is possibly not with this script. Where do you declare Item as a class/structure?

Jun 30 '12 at 01:40 PM Datael
(comments are locked)
10|3000 characters needed characters left

1 answer: sort oldest

Either Item doesn't exist, or it's in a JS file. In which case, put it in Standard Assets.

more ▼

answered Jun 30 '12 at 03:27 PM

Berenger gravatar image

Berenger
11k 12 19 53

It's not in a JS file. I tried to put the file into the Standard Assets, but the error it's same. :S

Jun 30 '12 at 03:51 PM Krumplee14

So do you even have the "Item" class? It's quite obvious that the compiler can't find a class with that name, so you don't have one. Maybe you mistyped it? Remember case-sensitivity! "item" is not the same as "Item".

Jun 30 '12 at 03:56 PM Bunny83

Does Item exist then ? It's not a protection's level or the compiler would say it.

Jun 30 '12 at 03:58 PM Berenger

YEAH. It's good. Thx for help! The Item.cs was missed. :)

Jun 30 '12 at 04:52 PM Krumplee14
(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:

x4172
x224
x35

asked: Jun 30 '12 at 01:29 PM

Seen: 377 times

Last Updated: Jun 30 '12 at 04:52 PM