Created
March 19, 2013 20:34
-
-
Save bzgeb/5199863 to your computer and use it in GitHub Desktop.
Custom cursor (software & hardware)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class CustomCursor : MonoBehaviour { | |
public Texture2D cursor; | |
public int width = 32; | |
public int height = 32; | |
// void Start() { | |
// Screen.lockCursor = true; | |
// Screen.showCursor = false; | |
// } | |
void OnGUI() { | |
if ( MouseInput.lockCursor ) { | |
Vector2 mousePosition = MouseInput.position; | |
GUI.DrawTexture( new Rect(mousePosition.x - (width / 2), Screen.height - (mousePosition.y + (height / 2)), width, height), cursor); | |
} | |
} | |
void Update() { | |
if ( !MouseInput.lockCursor ) { | |
Cursor.SetCursor(cursor, new Vector2(width / 2, height / 2), CursorMode.Auto); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment