I started following this tutorial on youtube and I got to a point where their is just one error from stopping me. Then I researched it a lot of people had this problem but so I found a completed version of the script that was released online I tested it out and I still get the single error.
//my error
Assets/my menu/FOLLOW ME/MYGUI/MyGui.cs(13,22): error CS0246: The type or namespace name `Item’ could not be found. Are you missing a using directive or an assembly reference?
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;
public float closeButtonWidth = 20;
public float closeButtonHight = 20;
private List<Item> _lootItems;
private bool _displayLootWidnows = false;
private float _offset = 10;
private const int LOOT_WINDOWS_ID = 0;
private Rect _lootWindowsRect = new Rect(0,0,0,0);
private Vector2 _lootWindowSlider = Vector2.zero;
private GameObject chest;
// Use this for initialization
void Start () {
_lootItems = new List<Item>();
}
public void OnEnable() {
Messenger<int, GameObject>.AddListener("PopulateChest", PopulateChest);
}
public void OnDisable() {
Messenger<int, GameObject>.RemoveListener("PopulateChest", PopulateChest);
}
// Update is called once per frame
void Update () {
}
void OnGUI() {
if(_displayLootWidnows)
_lootWindowsRect = GUI.Window(LOOT_WINDOWS_ID, new Rect(_offset, Screen.height - (_offset + lootWindowHeight), Screen.width - (_offset * 2), lootWindowHeight), LootWindow, "Loot Window");
}
private void LootWindow(int id) {
if(GUI.Button(new Rect(_lootWindowsRect.width - 20, 0, closeButtonWidth, closeButtonHight), "x")) {
ClearWindow();
}
_lootWindowSlider = GUI.BeginScrollView(new Rect(_offset * .5f, 15, _lootWindowsRect.width - 10, 70), _lootWindowSlider, new Rect(0, 0, (_lootItems.Count * buttonWidth) + _offset, buttonHeight * _offset));
for(int cnt = 0; cnt < _lootItems.Count; cnt++) {
GUI.Button(new Rect(5 + (buttonWidth * cnt), 8, buttonWidth, buttonHeight), cnt.ToString());
}
GUI.EndScrollView();
}
private void PopulateChest(int x, GameObject go) {
chest = go;
for(int cnt = 0; cnt < x; cnt++) {
_lootItems.Add(new Item());
_displayLootWidnows = true;
}
}
private void ClearWindow() {
_lootItems.Clear();
chest.GetComponent<Chest>().OnMouseUp();
chest = null;
_displayLootWidnows = false;
}
}