Skip to content

Instantly share code, notes, and snippets.

@keijiro
Created August 19, 2011 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keijiro/1156433 to your computer and use it in GitHub Desktop.
Save keijiro/1156433 to your computer and use it in GitHub Desktop.
Detect click on the outside of GUI.
var guiIsHot : boolean;
function Update() {
if (Input.GetMouseButton(0) && GUIUtility.hotControl != 0) {
guiIsHot = true;
}
if (Input.GetMouseButtonUp(0)) {
if (!guiIsHot) {
Debug.Log("Hooray!");
}
guiIsHot = false;
}
}
function OnGUI() {
GUILayout.Button("button1");
GUILayout.Button("button2");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment