Skip to content

Instantly share code, notes, and snippets.

@scryptonite
Created August 28, 2016 04:24
Show Gist options
  • Save scryptonite/d3a3f19563e18e67f923ed90a190fe33 to your computer and use it in GitHub Desktop.
Save scryptonite/d3a3f19563e18e67f923ed90a190fe33 to your computer and use it in GitHub Desktop.
LD36/Code/Scryptonite/ChangeCursor.cs
/*
* @Scryptonite
*
* Just attach this component to any GameObject with a Collider.
*
* If you end up using my cursor set, the hotspot is pretty good at <23, 26>.
*
* You might want to update the Texture Type of whatever cursor you use to "Cursor".
*
* Don't forget to update the default cursor and hotspot under Edit/Project Settings/Player.
*
*/
using UnityEngine;
public class ChangeCursor : MonoBehaviour {
public Texture2D mouseOverCursor;
public Vector2 hotspot = Vector2.zero;
public CursorMode cursorMode = CursorMode.Auto;
void OnMouseEnter() {
Cursor.SetCursor(mouseOverCursor, hotspot, cursorMode);
}
void OnMouseExit() {
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment