Hi all. I'm having some GUI button issues. I have a piece of code right now for when you select some objects a test question comes up, telling you to select a specific object. After you select that object I want a GUI button to pop up that says either correct or incorrect. For the most part I have it, only when I release the mouse button the GUI button disappears. I have tried different combos of GetMouseButton, GetMouseButtonDown, and GetMouseButtonUp. But when I use GetMouseButtonDown in place of GetMouseButton the GUI button doesn't even show up at all. My code follows:
if(allObjectsClicked)
{
if(isClicked == false)
{
GUI.Box (new Rect (350,10,350,120), "Please click the learning cube.");
{
if (Input.GetMouseButton(1))
{
if (Physics.Raycast (ray, out hit))
{
if(hit.collider.gameObject.name == "learningCube2" || hit.collider.gameObject.name == "learningCylinder2")
{
isClicked = true;
}
}
}
}
}
if(isClicked)
{
if (Input.GetMouseButton(1))
{
if (Physics.Raycast (ray, out hit))
{
if(hit.collider.gameObject.name == "learningCube2")
{
if(GUI.Button(new Rect (350, 10, 350, 120), "That was correct. You may now continue."))
{
navButtonEnabled = true;
Debug.Log("Why isn't the GUI button staying, jerk?");
}
}
else
{
GUI.Box(new Rect (350, 10, 350, 120), "Sorry, the correct answer was the cube. Click to advance.");
Debug.Log("Why isn't the GUI box staying part II");
navButtonEnabled = true;
}
}
}
}
}