Search Unity

GUI problems

Discussion in 'Immediate Mode GUI (IMGUI)' started by taragon, Oct 10, 2011.

  1. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    Not sure how I would fix the following:
    Code (csharp):
    1. function OnGUI() {
    2.     if (npctrigger)
    3.     {
    4.     //GUI.BeginGroup (Rect (Screen.width / 2 - 50, Screen.height / 2 - 50, 100, 100));
    5.    
    6.         if (yesbutton)
    7.         {
    8.             GUI.Box (Rect(0, 0, 100, 100), "Enter treasure chest");
    9.            
    10.         }
    11.         else if (nobutton)
    12.         {
    13.             GUI.Box (Rect(0, 0, 100, 100), "You cannot enter");
    14.         }
    15.         else
    16.         {
    17.             GUI.Box (Rect(0, 0, 100, 100), "Give inventory?"); 
    18.             if (GUI.Button (Rect(25, 25, 50, 30), "Yes"))
    19.             {
    20.                     yesbutton = true;
    21.                     Debug.Log("True");
    22.             }
    23.        
    24.             if (GUI.Button (Rect(25, 25, 50, 30), "No"))
    25.             {
    26.                     nobutton = true;
    27.                     Debug.Log("No");
    28.  
    29.             }
    30.         }
    31.    
    32.     }
    33. }
     

    Attached Files: