Search Unity

Need help with GUI

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

  1. GamesOnAcid

    GamesOnAcid

    Joined:
    Jan 11, 2016
    Posts:
    283
    Code (JavaScript):
    1. var Note : Texture;
    2. var noteInRange;
    3.  
    4. public var guiSkin : GUISkin;
    5.  
    6. function Start()
    7. {
    8.     Note = Resources.Load("TableNote");
    9. }
    10.  
    11. function OnTriggerStay()
    12. {
    13.     noteInRange = true;
    14. }
    15.  
    16. function OnTriggerExit()
    17. {
    18.     noteInRange = false;
    19. }
    20.  
    21. function OnGUI()
    22. {
    23.     if(noteInRange == true)
    24.     {
    25.         GUI.skin = guiSkin;
    26.         GUI.Label (Rect (Screen.width/2-50, Screen.height/2-55, 120, 50), "Read Note");
    27.        
    28.         if(Input.GetKeyDown(KeyCode.E))
    29.         {
    30.             GUI.DrawTexture(Rect(100,100,100,100), Note);
    31.         }
    32.     }
    33. }
    34.  
    Can I get some pointers on the best way to display an image on screen? This doesn't draw it to the screen, but I want it to.
     
  2. gorbit99

    gorbit99

    Joined:
    Jul 14, 2015
    Posts:
    1,350
    You can put the image inside a GUI.Box, in a GUI.Label, etc., just instead of a string, use the image.