- Home /
Why can't i click a button when in first person?
I have made a menu pop up when i press Esc but i cant click the buttons as when i try to click the buttons the mouse disappears. if there is scrip involved in doing this please do it in c#.
Answer by allenallenallen · Jun 06, 2016 at 11:18 AM
That's because the First Person Controller uses MouseLook.cs to lock the cursor to the middle of the screen. I wouldn't use the First Person Controller in the Standard Asset if I were you since it's quite basic.
However, if you really want to keep using it, just uncheck the Lock Cursor option like the image shown right here: http://image.prntscr.com/image/5f0cfff147dc454c9a66c8f67166cf1e.png
Yes but how could you hide the mouse when in the game but when the ESC button is pressed the mouse become free to click things?
Use this:
https://docs.unity3d.com/ScriptReference/Cursor-visible.html
Simply set the cursor to invisible at the start.
Then when ESC is pressed, toggle the visibility.
Cursor.visible = !Cursor.visible;
Thanks y'all this was driving me nuts. I thought it was something wrong with my UI! But it's the standard FPS asset that was making my GUI buttons not respond some of the time.
@allenallenallen Wow! Thanks for this image/answer. You have no idea how this issue (Lock cursor check box) has frustrated my work for many days. I could not get the FPS Controller to click a button. I was starting to think my laptop was cursed (LOL) and wondering why I was so rubbish at simple UI buttons when everyone seems to get it.
Now, it works like magic. $$anonymous$$any thanks once again!
Uncheck FPS controller mouse lock. This works for me! Thanks
Answer by PokerBob · Oct 26, 2019 at 06:14 PM
OMG its become clearer now, after struggling for a day to be able to click a ui button after checking all the raycasting whatnot's and attached components seemingly correct, i now know the issue (i think) is with the FPS looking in the wrong place and can work around it - many thanks for the pointer.
Your answer

Follow this Question
Related Questions
Change button texture when its clicked 1 Answer
GUI based character control 2 Answers
Can I change GUIButton behaviour? 1 Answer
Buttons that remove themselves when clicked mess up other gui elements 2 Answers
how to call a gameobject in one function(mouse selection) to another function (GUI) 1 Answer