When i equip a item from my inventory to equippment that is going ok but back nothing happens and my equippment tab disapears and i cant do anything (btw tut from JesseEtzler0)
my error is : NullReferenceException: Object reference not set to an instance of an object
my code is :
import System.Collections.Generic;
//Holding all of our items.
var items : Item[];
//Inventory
var MainInventory : List.<Item> = new List.<Item>();
//Equip Menu [0 = helm, 1 = shoulders, 2 = gloves, 3 = pants, 4 = boots, 5 = ring, 6 = neckless]
var EquipMenu : Item[];
var Power : int = 0;
function Start ()
{
MainInventory.Add(items[0]);
MainInventory.Add(items[0]);
MainInventory.Add(items[1]);
EquipMenu[0] = null;
}
function OnGUI ()
{
for(var x =0; x < MainInventory.Count; x++)
{
if(GUI.Button(Rect(Screen.width / 2, Screen.height / 2 + (20 * x), 100, 20), GUIContent ( MainInventory[x].Name, "Stamina! " + MainInventory[x].Stamina)))
{
if(MainInventory[x].itemType == MainInventory[x].itemType.helm)
{
if(EquipMenu[0] != null && EquipMenu[0].equiped == true)
{
MainInventory.Add(EquipMenu[0]);
}
EquipMenu[0] = null;
EquipMenu[0] = MainInventory[x];
Power += EquipMenu[0].Power;
MainInventory.RemoveAt(x);
Debug.Log(Power);
}
else if(MainInventory[x].itemType == MainInventory[x].itemType.shoulders)
{
EquipMenu[1] = MainInventory[x];
MainInventory.RemoveAt(x);
}
}
}
for(var y = 0; y < EquipMenu.length; y++)
{
if(EquipMenu[y] != null)
{
if(GUI.Button(Rect(Screen.width / 2 - 150, Screen.height / 2 + (20 * y), 100, 20), "" + EquipMenu[y].Name))
{
if(EquipMenu[y] != null)
{
MainInventory.Add(EquipMenu[y]);
Power -= EquipMenu[y].Power;
EquipMenu = null;
Debug.Log(Power);
}
}
}
}
}