hello there, i was wondering if anyone could help me with my inventory system. I have created an open/close button, which opens a box, with 30 buttons inside to hold the items.
Where do i go from here?
My code:
import System.Collections.Generic;
var buttonText = "Open";
var buttonOpen : boolean = true;
var openGUI : boolean = false;
var playerInventory : List.<ItemClass> = new List.<ItemClass>();
var button1;
var AddItem : AddItem;
function Start () {
}
function OnGUI() {
if(GUI.Button(new Rect(20,20,80,30),buttonText))
{
if(buttonText == "Open")
{
buttonText = "Close";
}
else
buttonText = "Open";
}
if(buttonText == "Close")
{
openGUI = true;
GUI.Box(Rect(Screen.width/2-300, Screen.height/2-250, 600, 500), "Inventory");
//top row
GUI.Button(Rect(Screen.width/2-275, Screen.height/2-200, 50, 50), playerInventory[x].icon); x++;
GUI.Button(Rect(Screen.width/2-175, Screen.height/2-200, 50, 50), playerInventory[x].icon); x++;
GUI.Button(Rect(Screen.width/2-75, Screen.height/2-200, 50, 50), playerInventory[x].icon); x++;
GUI.Button(Rect(Screen.width/2+25, Screen.height/2-200, 50, 50), playerInventory[x].icon); x++;
GUI.Button(Rect(Screen.width/2+125, Screen.height/2-200, 50, 50), playerInventory[x].icon); x++;
GUI.Button(Rect(Screen.width/2+225, Screen.height/2-200, 50, 50), playerInventory[x].icon); x++;
//second row
GUI.Button(Rect(Screen.width/2-275, Screen.height/2-110, 50, 50), playerInventory[x].icon); x++;
GUI.Button(Rect(Screen.width/2-175, Screen.height/2-110, 50, 50), playerInventory[x].icon); x++;;
GUI.Button(Rect(Screen.width/2-75, Screen.height/2-110, 50, 50), playerInventory[x].icon); x++;
GUI.Button(Rect(Screen.width/2+25, Screen.height/2-110, 50, 50), playerInventory[x].icon); x++;
GUI.Button(Rect(Screen.width/2+125, Screen.height/2-110, 50, 50), playerInventory[x].icon); x++;
GUI.Button(Rect(Screen.width/2+225, Screen.height/2-110, 50, 50), playerInventory[x].icon); x++;
//third row
GUI.Button(Rect(Screen.width/2-275, Screen.height/2-10, 50, 50), playerInventory[x].icon); x++;
GUI.Button(Rect(Screen.width/2-175, Screen.height/2-10, 50, 50), playerInventory[x].icon); x++;
GUI.Button(Rect(Screen.width/2-75, Screen.height/2-10, 50, 50), "15");
GUI.Button(Rect(Screen.width/2+25, Screen.height/2-10, 50, 50), "16");
GUI.Button(Rect(Screen.width/2+125, Screen.height/2-10, 50, 50), "17");
GUI.Button(Rect(Screen.width/2+225, Screen.height/2-10, 50, 50), "18");
//fourth row
GUI.Button(Rect(Screen.width/2-275, Screen.height/2+90, 50, 50), "19");
GUI.Button(Rect(Screen.width/2-175, Screen.height/2+90, 50, 50), "20");
GUI.Button(Rect(Screen.width/2-75, Screen.height/2+90, 50, 50), "21");
GUI.Button(Rect(Screen.width/2+25, Screen.height/2+90, 50, 50), "22");
GUI.Button(Rect(Screen.width/2+125, Screen.height/2+90, 50, 50), "23");
GUI.Button(Rect(Screen.width/2+225, Screen.height/2+90, 50, 50), "24");
//fourth row
GUI.Button(Rect(Screen.width/2-275, Screen.height/2+190, 50, 50), "25");
GUI.Button(Rect(Screen.width/2-175, Screen.height/2+190, 50, 50), "26");
GUI.Button(Rect(Screen.width/2-75, Screen.height/2+190, 50, 50), "27");
GUI.Button(Rect(Screen.width/2+25, Screen.height/2+190, 50, 50), "28");
GUI.Button(Rect(Screen.width/2+125, Screen.height/2+190, 50, 50), "29");
GUI.Button(Rect(Screen.width/2+225, Screen.height/2+190, 50, 50), "30");
}}
else
{
openGUI = true;
}
if(x == 30)
{
AddItem.canLoot = false;
}