I’m using a simple script to replace the windows cursor with a custom one. However, before turning the windows cursor off, I noticed that my cursor lags behind it when I move the mouse. It’s not gamebreaking, but it’s annoying.
var cursorTexture : Texture;
function OnGUI() {
GUI.DrawTexture(Rect(Input.mouseposition.x, (Screen.height - Input.mousePosition), 64,64), cursorTexture);
}
I doubt it’s related to performance considering I’m testing this on a scene that only contains a Camera (with this script attached, of course).
Is this one of those things that are hard-coded into the engine or is there an alternative method that yields no lag?
The OnGUI() function is known to be slow. Unity 3.5 will hopefully have an improved GUI system.
But, I do not think it is the slowness of this function that is causing the issue.
I do think that it is a performance issue but not what you are thinking of. The OnGUI() function might not be called every frame which would cause that lag. You might be able to use GUITexture for no lag.
Of course, when you hide the Windows cursor, the lag would barely become noticeable.
After checking you Cursor position code, i’d say you better use Update() to update cursor postion and OnGUI() only to display it. That way you delete the lag caused by OnGUI calls.