我正在開發一個遊戲,其中需要在光標指向按鈕時更改光標圖標,並且在未指向按鈕時保留回正常狀態。到目前爲止,我已經做到了這一點,但沒有什麼好的,我有什麼建議,哪裏出錯了? 我附上的按鈕這個腳本...當鼠標懸停在按鈕上時更改光標的圖標
using UnityEngine;
using System.Collections;
public class cursor : MonoBehaviour {
Vector2 mouse;
int w =32;
int h=32;
public Texture2D cursor1;
// Use this for initialization
void Start() {
Cursor.visible = true;
}
// Update is called once per frame
void Update() {
mouse = new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y);
}
void OnMouseOver()
{
Cursor.SetCursor (cursor1, Vector2.zero, CursorMode.Auto);
}
void OnMouseExit()
{
Cursor.SetCursor (null,Vector2.zero,CursorMode.Auto);
}
}