Quantcast
Viewing latest article 29
Browse Latest Browse All 90

Answer by Kleptomaniac

You should really be using the [Event class][1] for event handling in OnGUI(), due to the fact that the OnGUI() function has multiple passes per frame and will thus repeat Input calls more times than necessary. Instead of `if (Input.GetButtonDown(KeyCode.Alpha1)) {` try using `if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Alpha1) {` Other than that, your code is fine. What is your question? [1]: http://docs.unity3d.com/Documentation/ScriptReference/Event.html

Viewing latest article 29
Browse Latest Browse All 90

Trending Articles