溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

[unity3d]自定義鼠標指針

發(fā)布時間:2020-02-27 06:09:37 來源:網(wǎng)絡 閱讀:386 作者:蓬萊仙羽 欄目:游戲開發(fā)

思路:使用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);
    }
}
向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內(nèi)容。

un %d
AI