using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; // 鼠标移入UI时光标改变 public class CursorChanger : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler { public Texture2D handCursor; // 用于存放小手光标图标 public Vector2 hotSpot = new Vector2(0, 0); // 设置光标热点 // 鼠标移入时调用 public void OnPointerEnter(PointerEventData eventData) { // 设置光标为小手图标 Cursor.SetCursor(handCursor, hotSpot, CursorMode.Auto); } // 鼠标移出时调用 public void OnPointerExit(PointerEventData eventData) { // 恢复为默认光标 Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto); } }