首页 > 代码库 > 设置鼠标指针图片代码

设置鼠标指针图片代码

using UnityEngine;
using System.Collections;

public class mouseCursor : MonoBehaviour {

    /// <summary>
    /// 变换样式
    /// </summary>
    public Texture2D cursorTexture;
    /// <summary>
    /// 默认鼠标样式
    /// </summary>
   public Texture2D fTexture;
    /// <summary>
    /// 设置鼠标默认方式
    /// </summary>
    public CursorMode cursorMode = CursorMode.Auto;
    
/// <summary>
/// 在第一次调用update之前调用
/// </summary>
public void Start()
    {
        ///设置鼠标样式
        Cursor.SetCursor(fTexture, Vector2.zero, cursorMode);
    }
    /// <summary>
    /// 鼠标退出时调用
    /// </summary>
    public void onm ouseExit()
    {
        ///设置鼠标样式
        Cursor.SetCursor(fTexture, Vector2.zero, cursorMode);
    }
    /// <summary>
    /// 鼠标进入时调用
    /// </summary>
    public void onm ouseEnter()
    {
        Cursor.SetCursor(cursorTexture, Vector2.zero, cursorMode);
    }
}

 

设置鼠标指针图片代码