Hi guys,
Im trying to detect mouse overs on some gui elements. As I understand it I should use GUILayer.HitTest(). Im using:
using UnityEngine;
class CodeFile1 : MonoBehaviour
{
public void OnGUI()
{
GUI.BeginGroup(new Rect(0, 0, 200, 200));
GUI.Box(new Rect(10, 10, 100, 100), "lalala");
GUI.EndGroup();
}
void Update()
{
GUILayer l = (GUILayer)FindObjectOfType(typeof(GUILayer));
GUIElement e = l.HitTest(Input.mousePosition);
if (e != null) Debug.Log(e.name);
}
}
HitTest() always return null. Any gotcha’s I should know about?
Thanks, Bas