[unity3d]自定义鼠标指针
思路:使用Screen.showCursor = false; 将鼠标光标隐藏。然后用其它图片根随鼠标移动,模拟鼠标指针。
参考代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 var myCursor:Texture2D; var cursorSizeX: int = 32;// set to width of your cursor texture var cursorSizeY: int = 32;// set to height of your cursor texture var condition = true; function OnMouseEnter(){ condition = false; Screen.showCursor = false; } function OnMouseExit(){ condition = true; Screen.showCursor = true; } function OnGUI(){ if(!condition){ GUI.DrawTexture (Rect(Input.mousePosition.x-cursorSizeX/2 + cursorSizeX/2, (Screen.height-Input.mousePosition.y)-cursorSizeY/2 + cursorSizeY/2, cursorSizeX, cursorSizeY),myCursor); } }声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。