Hi, due to Oculus Rift, I need to lock the mouse but not in the middle, cause the middle, when you are using Oculus, is not the middle of the screen. Using Oculus you have 2 screens and I need to lock the cursor (or use another method) cause I’m using the Oculus tracker (with a drawed crosshair) to move the camera and trigger events. But the locked cursor is in the middle of the 2 Oculus screens and not matches with the crosshair (crosshair is well positioned). There’s the code I’m using:
// True if the menu is open and mouse is unlocked
var MenuOpen : boolean = false;
function Start () {
UpdateCursorLock();
Screen.showCursor = true;
}
function Update() {
// Check whether the menu button was released
if (Input.GetButtonUp("MenuOpen")) {
MenuOpen = !MenuOpen;
UpdateCursorLock();
}
}
// Called each time the Gui needs to be drawn
function OnGUI () {
if (!MenuOpen) {
// Draw the crosshair
// Center the text inside the label
var centeredStyle = GUI.skin.GetStyle("Label");
centeredStyle.alignment = TextAnchor.MiddleLeft;
// Draw the label at the center of the screen
GUI.Label (Rect (Screen.width/4+60, Screen.height/2-25, 100, 50), "O", centeredStyle);
}
}
function UpdateCursorLock() {
Screen.lockCursor = !MenuOpen;
Screen.showCursor = MenuOpen;
}