Periksa apakah mouse berada di frame unity

// If you want to hide the mouse when it is in frame, use this:

var mouseLocation = Camera.current.ScreenToViewportPoint(Input.mousePosition);
        var outOfFrame = Mathf.Min(mouseLocation.x, mouseLocation.y) < 0 ||
                         Mathf.Max(mouseLocation.x, mouseLocation.y) > 1;
        UnityEngine.Cursor.visible = outOfFrame;

// If you want to prevent the mouse from leaving frame:

UnityEngine.Cursor.lockCursor = true;
Slush