- Home /
Unity 4.6 GUIUtility.hotControl
Hello, I have an if statement that checks if I'm clicking a GUI element or not:
if (Input.GetMouseButtonDown (0) && GUIUtility.hotControl == 0)
But it doesn't seem to work with the new GUI system in Unity version 4.6, because the GUI seems to returns 0.
Could anyone tell me what is the new way of doing it?
Thank you.
Answer by Alessio89 · Aug 22, 2014 at 08:56 PM
using UnityEngine.EventSystems;
[...]
if (Input.GetMouseButtonDown(0) && EventSystemManager.currentSystem.IsPointerOverEventSystemObject())
Had the same exact doubt this morning and asked the forum for an answer :)
Alessio89, your answer doesn't work for me. I don't know why, Unity just doesn't recognize EventSystem$$anonymous$$anager.currentSystem.IsPointerOverEventSystemObject()
Ins$$anonymous$$d, what worked is the following :
if (!EventSystem.current.IsPointerOverGameObject()) {
}
That might help some in need too.
Cheers, bRo
This is still valid with Unity 2018.2.1f1. One more thing is that you can still enable clicks through some UIs elements by disabling their Raycast Target variable.
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
GUI.Textfield backspace control + Button Style problem 0 Answers
Getting almost nowhere with my buttondrag script 1 Answer
GUI Scripting button controls 1 Answer
How can I create an RTS style build function into my GUI 0 Answers