0

I am trying to make a scene where when you click on an object (like a hotspot) a window pops up on the screen like in the screenshot. I got this to work using GUI textures however once the pop up displays it stays on the screen. Is there a way for me to click the texture and make it disappear?

Here is my code:

#pragma strict
private var guiShow : boolean = false;
var riddle : Texture;

function OnMouseDown () {
    guiShow = true;
}

function OnGUI()
{
    if(guiShow == true)
    {
        GUI.DrawTexture(Rect(Screen.width / 4.5, Screen.height / 4, 1024, 512), riddle);
    }
}

GUI Texture Displaying

zhm
  • 3,513
  • 3
  • 34
  • 55
  • 1
    You are using the old IMGUI. I suggest you watch Unity's tutorial for [UI](https://unity3d.com/learn/tutorials/topics/user-interface-ui). Once you understand how to create UI controls, [this](https://stackoverflow.com/questions/41391708/how-to-detect-events-on-ui-and-gameobjects-with-the-new-eventsystem-api/41392130#41392130) is how to detect click on UI components or GameObjects. – Programmer Mar 29 '17 at 09:05
  • Please post your code as text, instead of picture. – zhm Mar 29 '17 at 09:06
  • #pragma strict private var guiShow : boolean = false; var riddle : Texture; function OnMouseDown () { guiShow = true; } function OnGUI() { if(guiShow == true) { GUI.DrawTexture(Rect(Screen.width / 4.5, Screen.height / 4, 1024, 512), riddle); } } – Daniel Dixon Mar 29 '17 at 09:10
  • @DanielDixon Post your code in question, not as comment. – zhm Mar 29 '17 at 09:14
  • sorry there you go – Daniel Dixon Mar 29 '17 at 09:15

0 Answers0