I’ve tried a couple different solutions I’ve seen posted either here, in the forums, or on the Unify wiki, but none of the scripts I’ve used to create a custom mouse pointer have worked. Even if I enter the code exactly as in the examples that have worked for others (except for using my own files, of course) they generate a multitude of errors. Is there anyone that can point me in the right direction?
I just tried this one with a local png image and that worked fine for me. I preferred it in C though…
using UnityEngine;
using System.Collections;
public class CursorController : MonoBehaviour {
public Texture cursorImage;
// Use this for initialization
void Start ()
{
Screen.showCursor = false;
}
// Update is called once per frame
void OnGUI ()
{
Vector3 mousePos = Input.mousePosition;
Rect pos = new Rect(mousePos.x,Screen.height - mousePos.y,cursorImage.width,cursorImage.height);
GUI.Label(pos,cursorImage);
}
}
I am using this (also found here somewhere), and it works like a charm:
var myCursor:Texture2D;
var cursorSizeX: int = 32; // set to width of your cursor texture
var cursorSizeY: int = 32; // set to height of your cursor texture
function Start(){
Screen.showCursor = false;
}
function OnGUI(){
GUI.DrawTexture (Rect(Input.mousePosition.x-cursorSizeX/2, (Screen.height-Input.mousePosition.y)-cursorSizeY/2, cursorSizeX, cursorSizeY),myCursor);
}