- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
thekemkid · Oct 16, 2013 at 05:18 PM ·
mouseclick
Clicking button locks mouse, doesn't activate button. how do I fix this?
Hey guys, I have a piece of code that locks the mouse and hides it when the player clicks the screen, but when I try to click a button on the screen after the mouse has been released, the code that locks it must override it and locks the cursor instead of activating the buttons functions. the piece's of code in question are
update(){
if(Input.GetKey(KeyCode.Mouse0)){ //locks mouse
Screen.showCursor = false;
Screen.lockCursor = true;
}
if(Input.GetKeyDown(KeyCode.Escape)){ //releases mouse
Screen.showCursor = true;
Screen.lockCursor = false;
}
}
and
function OnGUI() {
//button I wish to click.
if(GUI.Button(Rect(0, 0, 240, 40), "(Press escape to free mouse)\\n"+
"(Click here to return to main menu)")){
Application.LoadLevel("MainMenu");
}
}
Comment
Your answer
