- Home /
It seems like a Event.current.clickCount problem with Unity 4
Hello,
I updated to Unity 4.1.0 recently from 3.5 on a Mac. I am using a C# script called GUILayoutx.cs taken from the very handy FileBrowser in the Wiki. There's an if statement there, which checks if a GUI element is doubled clicked as follows:
else if (hover && callback != null && Event.current.type == EventType.MouseUp && Event.current.clickCount == 2)
{
//action to perform
callback(i);
Debug.Log(i);
Event.current.Use();
}
Before the update everything was functioning, but anymore the double-clicking is not. I narrowed down the problem and I believe it is the "Event.current.clickCount == 2" to blame, because when I set the value to 1 it works, while otherwise it doesn't enter the if statement.
I found this: "Mac OS X: Event.clickCount behavior for double-clicks now matches windows (clickCount is always 1 for MouseUp events)." taken from here. Do you think it is might also related?
Or maybe the problem goes deeper and for some reason another condition is not fulfilled before the second click. For instance the callback becomes null very fast...
Thank you!
Answer by entity476 · Mar 22, 2013 at 02:33 PM
All right! I am searching for hours and missed to check for an update to the mentioned script file. And, indeed, the answer is there! I 'm not sure yet what the problem was, but this fix...fixes it!
Oh man, I feel like an idiot now as well. Thanks for your post!