- Home /
Overlapping GUITexture UI Buttons
Hi,
What I have is a UI that will pop up when the user clicks the menu button. The new window will now take up the entire screen and overlay notop of the menu button.
My problem is that when I open the pop up window and I click in the position of the menu button, it still registers that click on the menu button. If I wanted to put a different button in it's place when the window is opened, there is a conflict and both the new button and the menu button would be registered as clicked.
I am using GUITexture for this. Could someone give me some guidance?
Answer by Cherno · May 18, 2014 at 03:21 PM
Three things to avoid the overlapping issue:
GUIUtility.hotControl when checking fo the GUI.Button press
Event.current.Use() immediately after the button is pressed
return at the end of the button-press code (just to be sure).
Could you explain to me about using hot.control?
if I have button 1 and 2 overlapping in a new window and my code looks like:
if(Input.Get$$anonymous$$ouseButtonDown(0) && GUIUtility.hotControl == 0 && button1.guiTexture.HitTest(Input.mousePosition))
{
print ("hit button 1");
}
if(Input.Get$$anonymous$$ouseButtonDown(0) && GUIUtility.hotControl == 0 && button2.guiTexture.HitTest(Input.mousePosition))
{
print ("hit button 2");
}
I am still getting print button 1 + button 2. I want to only have button 1 printed and button 2 printed if I decide to click button 2 separately.
Answer by getyour411 · May 18, 2014 at 02:54 PM
http://answers.unity3d.com/questions/709639/how-to-make-gui-object-prevent-clickingtouching-wh.html
Also look at GUI.ModalWindow
http://docs.unity3d.com/Documentation/ScriptReference/GUI.ModalWindow.html
Very common question, please search for questions/answers, tuts, vids, code snippets and other resources for additional information.
Your answer
Follow this Question
Related Questions
button drawn last not triggered 0 Answers
Animate GUI Elements 1 Answer
GUI Button overlap problem 1 Answer
Activate Gui Texture On Trigger Activate 1 Answer
Tic Tac Toe beginner 0 Answers