Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

GUI buttons

Discussion in 'Scripting' started by GamesOnAcid, Feb 10, 2016.

  1. GamesOnAcid

    GamesOnAcid

    Joined:
    Jan 11, 2016
    Posts:
    283
    Code (JavaScript):
    1. function OnGUI ()
    2. {
    3.     if(panelInRange == true)
    4.     {
    5.         GUI.Label (Rect (Screen.width/2-50, Screen.height/2-55, 120, 50), "Enter Code");
    6.     }
    7.    
    8.     if(panelInRange == true && panelIsActive == true)
    9.     {
    10.     GUI.Box (Rect (10,10,300,110), "Enter the security code");
    11.     if(GUI.Button(Rect (Screen.width/2-50, Screen.height/2-55, 120, 50), oneButton)){ playerEntry.Push(1); }
    12.     else
    13.     if(GUI.Button(Rect (Screen.width/2-50, Screen.height/2-55, 120, 50), twoButton)){ playerEntry.Push(2); }
    14.     else
    15.     if(GUI.Button(Rect (Screen.width/2-50, Screen.height/2-55, 120, 50), threeButton)){ playerEntry.Push(3); }
    16.     }
    17. }
    Basically, this is a keypad to input into a door. I am trying to place some button textures in place of the GUI buttons, but it tells me that this isn't proper to do like this. It tells me that 'No appropriate version of 'UnityEngine.GUI.Button' for the arg list '(UnityEngine.Rect, System.Type)' was found.' I declare the textures like
    Code (JavaScript):
    1. var oneButton = Texture;
    2. var twoButton = Texture;
    3. var threeButton = Texture;
    and according to http://docs.unity3d.com/ScriptReference/GUI.Button.html it appears I'm doing everything properly. Anyone see my error?
     
  2. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Any reason you are using the legacy system and not the new UI?
     
  3. hpjohn

    hpjohn

    Joined:
    Aug 14, 2012
    Posts:
    2,190
    var oneButton : Texture
     
  4. GamesOnAcid

    GamesOnAcid

    Joined:
    Jan 11, 2016
    Posts:
    283
    It wa
    It was just what I was used to, I'll update myself. Thanks!