Skip to content

Instantly share code, notes, and snippets.

@bzgeb
Created March 19, 2013 20:34
Show Gist options
  • Save bzgeb/5199863 to your computer and use it in GitHub Desktop.
Save bzgeb/5199863 to your computer and use it in GitHub Desktop.
Custom cursor (software & hardware)
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