Hello everyone,
I am working on an eyedropper and ran into an issue. How can I detect raw mouse events, such as mouse down, move, and up? I want to be able to detect these events even when outside the editor window. I am not using Unity’s old GUI system but instead a new UI system. In the OnGUI method when I check the current event the type is always either Repaint or Layout. It doesn’t fire mouse events.
private void OnGUI()
{
var ve = rootVisualElement.Q<VisualElement>(null, "color-picker-window-container");
if (ve != null)
{
ve.style.height = new StyleLength(position.height);
}
Event e = Event.current;
if (sampleEyedropper)
{
if (e.rawType == EventType.Repaint)
{
colorPicker.SampleColor(e.mousePosition);
}
}
if (e.rawType == EventType.MouseDown) //<-- Doesn't detect
{
Debug.Log("Down");
sampleEyedropper = false;
}
}