可以用Cursor根據遊戲類型的需要來去改變游標的操作,提供更好的遊戲體驗。
void Start()
{
Cursor.visible = false;
}
public Texture2D cursorTexture;
public CursorMode cursorMode = CursorMode.Auto;
public Vector2 hotSpot = Vector2.zero;
void Start()
{
Cursor.SetCursor(cursorTexture, hotSpot, cursorMode);
}
//鎖在畫面中央
Cursor.lockState = CursorLockMode.Locked;
//鎖在視窗中
Cursor.lockState = CursorLockMode.Confined ;
參考資料:
https://docs.unity3d.com/ScriptReference/Cursor.html
https://docs.unity3d.com/ScriptReference/Cursor.SetCursor.html