For my GUI, I'd like to use keep track of the mouse position while avoiding simply polling for the position every Update(). Ideally, I'd like to leverage the "mouseMove" event since then I can unnecessary code execution when the mouse position hasn't changed, but the mouseMove Event isn't fired in game (only the editor, see http://unity3d.com/support/documentation/ScriptReference/EventType.MouseMove.html).
Does anyone have a good workaround for this problem? Is there a efficient, standard way to capture mouse position that I'm just overlooking?
asked Sep 01 '11 at 10:32 PM
Since your problem is a high-cost operation which you need to do each move, solve this by comparing the mousePosition to what it was in the previous frame and avoid the operation when the change is zero. The actual cost of reading mousePosition is immaterial.
answered Sep 02 '11 at 12:41 AM