- Home /
Event problem in GUI
var a1 : boolean = false; var a2 : boolean = false; var a3 : boolean = false; var clickCount : int; var ab = 0;
function Start() { a1 = false; }
function OnGUI() { var e : Event = Event.current; if(a1 == true) { GUI.Label(Rect (100, 400, 250, 200),"Mouse clicks: "+ 1 ); }
if(a2 == true) { GUI.Label(Rect (100, 400, 250, 200),"Mouse clicks: "+ 2 ); }
if(a3 == true) { GUI.Label(Rect (100, 500, 250, 200),"Mouse clicks: "+ clickCount ); }
if (e.clickCount == 1 ) { a1 = true; a2 = false; Debug.Log("Mouse clicks: " + e.clickCount); }
if (e.clickCount == 2 ) { a2 = true; a1 = false; Debug.Log("Mouse clicks: " + e.clickCount); }
if (GUI.Button(Rect(8, 8, 128, 64), "BUTTON")) { if (Event.current.type == EventType.MouseDown && Event.current.clickCount ) clickCount +=1; a3 = true; a1 = false; }
}
Here in the first condition when user click on a screen using mouse it will display in label whether it is single or double click.
In the second condition when user click on a gui.button it will display how much number of click is performed on the button using counter.
Here i have used clcikcount event both the condition are working fine my problem is when i click on the button both condition are working.
Here i cannot able to stop the first event condition when i use second event condition i tried to use event.use not working to stop other event.
When user interact with gui.button and only gui.button event should work at that time
What is wrong in this coding
Your answer
Follow this Question
Related Questions
Blender like Camera Control Shortcuts 1 Answer
GUI Button sound problem, don´t work 1 Answer
Pause Menu background problem 0 Answers
Game looks messed up when i built it onto my iphone 1 Answer
Quit Game Button Not Working 3 Answers