using UnityEngine;
using System.Collections;
public class Cursor : MonoBehaviour
{
// Use this for initialization
void Start()
{
//在游戏启动时就隐藏系统鼠标指针
Screen.showCursor = false;
}
// Update is called once per frame
void Update()
{
//实时修改自身的坐标,注意GUITexture的位置是以屏幕左下角为(0,0)点,右上角为(1,1)点
transform.position = new Vector3()
{
x = 1 - (Screen.width - Input.mousePosition.x) / Screen.width,
y = 1 - (Screen.height - Input.mousePosition.y) / Screen.height,
};
}
}
本文介绍了一个Unity脚本,用于在游戏中实现自定义光标。该脚本通过禁用系统光标并根据鼠标位置更新游戏对象的位置来实现效果。
2034

被折叠的 条评论
为什么被折叠?



