Hey guys,
I’m wondering if there’s a way to script a custom mouse cursor now using the new uGUI (Unity’s new gui system)? I currently have a custom mouse cursor working, but it’s with the old GUI, and I’m noticing some bad mouse input lag with my code currently.
I’d like to transition to the new GUI with a custom mouse cursor, so I was hoping maybe someone had figured out a decent way of getting a custom cursor with the new GUI.
Here’s my current custom mouse code using the old GUI system, and like I said, I’m noticing annoying lag with this:
function OnGUI() {
//Custom cursor code (there is also a "showcursor" option to be enabled/disabled on Start().)
//*Note: I have to divide the mouse position by different amounts in order to compensate for any given cursor image (depending on its size)
if(cursorShowAttack1 == true) {
GUI.DrawTexture (Rect(Event.current.mousePosition.x-cursorSizeX1/4.2, Event.current.mousePosition.y-cursorSizeY1/5.3, cursorSizeX1, cursorSizeY1), attackCursor1);
}
else if(cursorShowFriendly1 == true) {
GUI.DrawTexture (Rect(Event.current.mousePosition.x-cursorSizeX1/4.2, Event.current.mousePosition.y-cursorSizeY1/5.3, cursorSizeX1, cursorSizeY1), friendlyCursor1);
}
else if(cursorShowChop2 == true) {
GUI.DrawTexture (Rect(Event.current.mousePosition.x-cursorSizeX1/4.2, Event.current.mousePosition.y-cursorSizeY1/5.3, cursorSizeX1 + 10, cursorSizeY1 + 10), chopTreeCursor1);
}
else {
//GUI.DrawTexture (Rect(Event.current.mousePosition.x-cursorSizeX/2, Event.current.mousePosition.y-cursorSizeY/2, cursorSizeX, cursorSizeY), yourCursor);
GUI.DrawTexture (Rect(Event.current.mousePosition.x-cursorSizeX1/4.2, Event.current.mousePosition.y-cursorSizeY1/5.3, cursorSizeX1, cursorSizeY1), yourCursor1);
}
}
function Start () {
//This statement is for getting a custom cursor to work in-game
Cursor.visible = false;
}