- Home /
Question by
some_developer · Jul 02, 2015 at 09:57 AM ·
mousemouselock
How to lock mouse cursor but still move camera
I tried myself but it would only lock at random moments, and when it would, i couldn't change where i looked. I am making a game where this would be very unwanted. Here is my code
#pragma strict
public var cursorTexture: Texture2D;
public var cursorMode: CursorMode = CursorMode.Auto;
public var hotSpot: Vector2 = Vector2.zero;
function OnMouseEnter() {
Cursor.SetCursor(cursorTexture, hotSpot, cursorMode);
}
function OnMouseExit() {
Cursor.SetCursor(null, Vector2.zero, cursorMode);
}
function Start () {
Screen.lockCursor = true;
}
function Update () {
Screen.lockCursor = true;
}
Comment
Answer by raja1250 · Jul 02, 2015 at 12:10 PM
if your need is to hide the cursor use Screen.showCursor instead of Screen.lockCursor
no, not really. Although i could make it invisible and add a cross hair gui, the mouse would still go out of the screen. Is there a way to keep it in the screen maybe?
Your answer
![](https://koobas.hobune.stream/wayback/20220613201622im_/https://answers.unity.com/themes/thub/images/avi.jpg)