Skip to content

Instantly share code, notes, and snippets.

@thebne
Created March 19, 2022 17:28
Show Gist options
  • Save thebne/491644eb6ae0cb1c8bc09c2575e3a5fc to your computer and use it in GitHub Desktop.
Save thebne/491644eb6ae0cb1c8bc09c2575e3a5fc to your computer and use it in GitHub Desktop.
Unity: detect arbitrary right click within custom editor
if (Event.current.button == 1
&& GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition)) {
if (Event.current.type == EventType.MouseUp) {
EditorGUI.DrawRect(GUILayoutUtility.GetLastRect(), new Color(1, 1, 1, 1f));
} else if (Event.current.type == EventType.MouseDown) {
Debug.Log($"Pressed on {propState}!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment