思路:使用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); } } |