Unity更改鼠标样式

来源:互联网 发布:淘宝开店审核 编辑:程序博客网 时间:2024/05/02 08:53


游戏制作过程中,往往会用到改变鼠标样式的功能,原理很简单,就是隐藏原有光标,再实时得在鼠标位置绘制一张图即可,脚本如下:


using UnityEngine;using System.Collections;public class cursor : MonoBehaviour {    //需要显示的鼠标的样式    public Texture texture;// Use this for initializationvoid Start () {        //让原始光标隐藏        Screen.showCursor = false;}    void OnGUI()    {        //获取鼠标位置        Vector3 mousepos=Input.mousePosition;        //绘制光标图        GUI.DrawTexture(new Rect(mousepos.x - texture.width / 2, Screen.height - mousepos.y - texture.height/2, texture.width, texture.height), texture);    }}


0 0