改变鼠标样式

var myCursor : Texture2D;  
var myClickCursor : Texture2D;  
var cursorWidth : float;  
var cursorHeight : float;  
  
private var isClicked : boolean = false;  
  
function Start () {  
    Screen.showCursor = false;  
}  
  
function Update () {  
    if (Input.GetMouseButton(0))   
        isClicked = true;  
  
    else  
        isClicked = false;  
}  
  
function OnGUI () {  
    var mousePos = Input.mousePosition;  
    if (isClicked)  
        GUI.DrawTexture(Rect(mousePos.x - cursorWidth / 2, Screen.height - mousePos.y - cursorHeight / 2,  
            cursorWidth, cursorHeight), myClickCursor);  
    else  
        GUI.DrawTexture(Rect(mousePos.x - cursorWidth / 2, Screen.height - mousePos.y - cursorHeight / 2,  
            cursorWidth, cursorHeight), myCursor);  
}  

 

posted @ 2013-05-06 20:58  码写人生  阅读(198)  评论(0)    收藏  举报