Trying to create a gui system. If you press image2 button i want another gui box and buttons to pop up asking to drop something. heres the code:
function OnGUI() {
var activateSubMenu = false;
inventoryStyle.normal.background = guiBackground;
if(iWasPressed && timesPressed == 1)
{
Time.timeScale = 0;
inventoryOpen = true;
GUI.Box(Rect(guiX, guiY, guiWidth, guiHeight), "inventory", inventoryStyle);
if(GUI.Button(Rect(15,30,75,75), slot1))
{
Instantiate(Resources.Load(deployObject.name), Vector3(transform.position.x, transform.position.y, transform.position.z + 5),
Quaternion.identity);
GUI.Box(Rect(Screen.width/2, Screen.height/2, 150, 150), "drop object?");
if(GUI.Button(Rect(Screen.width/2, Screen.height/2 + 5, 50,50), "Yes"))
{
}
if(GUI.Button(Rect(Screen.width/2, Screen.height/2 + 5, 50,50), "No"))
{
}
}
if(GUI.Button(Rect(160,30,75,75), slot2))
{
activateSubMenu = true;
}
if(activateSubMenu == true)
{
Debug.Log("clicked image2");
GUI.Box(Rect(0, 0, Screen.width, Screen.height), "drop object?");
if(GUI.Button(Rect(0, 0, 50,50), "Yes"))
{
}
if(GUI.Button(Rect(0, 0, 50,50), "No"))
{
}
}
}
if(timesPressed < 1 | timesPressed > 1)
{
inventoryOpen = false;
Time.timeScale = 1;
}
}
function ObjectImage() {
if(selectedObject.name == "testObject1")
{
slot1 = testImage;
if(slot1 == testImage)
{
Debug.Log("slot1 should be test image");
}
deployObject = gameObject.Find("testObject1");
}
if(selectedObject.name == "testObject2")
{
slot1 = testImage2;
deployObject = gameObject.Find("testObject2");
}
}
if(!slot1)
{
slot1 = defaultImage;
}
the problem is inside the Gui button with the text image and image 2. when i click those buttons, the buttons and box thats suppose to come after wont show. any pointers?