思路:使用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);
}
}
本文转蓬莱仙羽51CTO博客,原文链接:http://blog.51cto.com/dingxiaowei/1366216,如需转载请自行联系原作者
|