Cursor Locking / Replacement, only in editor?

Hey guys, I searched for some help but didn’t find any pertaining to my problem.

Im using Unity 2.5 on windoze, and im using the following code to hide the cursor, use a GUITexture instead and update it position based of mouse input, and lock the real cursor:

var normalCursor : Texture2D;        // The texture for when the cursor isn't near a screen edge
var nativeRatio = 1.3333333333333;   // Aspect ratio of the monitor used to set up GUI elements
private var lastPosition : Vector3;  // Where the mouse position was last
 
// Scale the cursor so it should look right in any aspect ratio, and turn off the OS mouse pointer
function Start()
{
    // Slightly weird but necessary way of forcing float evaluation
    var currentRatio : float = (0.0 + Screen.width) / Screen.height;
    transform.localScale.x *= nativeRatio / currentRatio;
    Screen.showCursor = false;
    lastPosition = Input.mousePosition;
	guiElement.texture = normalCursor;
	Screen.lockCursor = true;
}

function Update()
{
	// Check if the user is rotating using the right mouse button
	if (! Input.GetMouseButton(1))
	{
		var mousePos = Input.mousePosition;
		// If the mouse has moved since the last update
		if (mousePos != lastPosition)
		{
			lastPosition = mousePos;
			// Get mouse X and Y position as a percentage of screen width and height
			MoveMouse(mousePos.x/Screen.width, mousePos.y/Screen.height);
		}
	}
}
 
function MoveMouse(mousePosX : float, mousePosY : float)
{
    // If the mouse is on a screen edge, first make sure the cursor doesn't go off the screen,
    if (mousePosX < .005){mousePosX = .005;}
    if (mousePosX > .995){mousePosX = .995;}
    if (mousePosY < .005){mousePosY = .005;}
    if (mousePosY > .995){mousePosY = .995;}

 //   transform.position.x = mousePosX;
//    transform.position.y = mousePosY;
	transform.position.x += (Input.GetAxis("Mouse X")) * 0.02;
	transform.position.y += (Input.GetAxis("Mouse Y")) * 0.02;
}

It’s basically a slightly modified version of the replace cursor script found in the wiki. I just took out some parts.

The problem is, the cursor locking doesn’t work for me. Ever. Weither its in the editor or standalone it never kicks in, and im not sure if its a bug or I am just implementing it incorrectly.

Secondly, the above code works (besides the locking) fine, in the EDITOR, but when I build and run, it stops working. Does anyone know what would cause this? Any help is much appreciated. Thanks!

I’m pretty sure there is a bug related to showCursor / lockCursor both being used on windows. If you want to hide and lock the cursor, I beleive lockCursor does both.

I might be wrong.

As a matter of fact, I cannot get any input from the mouse buttons in the standalone exe, only in the editor. What gives?