Hi I’m new to Unity3D, so please pardon if I miss something on the documentation.
Example scenario would be to change this code:
var mouseScrollWheel : float = 0.0;
function processMouseScrollWheelValue1 () {
// code
}
/*
function processMouseScrollWheelValue2 () {
if (mouseScrollWheel != 0) {
// code
}
}
*/
function Update () {
mouseScrollWheel = Input.GetAxis ("Mouse ScrollWheel");
if (mouseScrollWheel != 0) {
processMouseScrollWheelValue1 ();
}
// or
/*
processMouseScrollWheelValue2 ();
*/
}
with something similar to:
function Start () {
Input.addEventListener ("Mouse ScrollWheel", processMouseScrollWheelValue);
}
function processMouseScrollWheelValue (e) {
// code
}
function Update () {
// code unrelated to Input
}
I’m not saying that it will improve the performance. However, I have an opinion that, if you put it on programmer’s point of view, it will save a heapload of time for other programmer / team member to scan, read, and refactors the code.
I wonder if there’s any way to register event listener to Input class? Or similar.