• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Eightbitdaydream · Jun 06, 2016 at 07:13 AM · guimouselookmouseclickgui-button

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#.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
3

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

Comment
Add comment · Show 6 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Eightbitdaydream · Jun 06, 2016 at 09:33 PM 0
Share

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?

avatar image allenallenallen Eightbitdaydream · Jun 07, 2016 at 02:23 AM 0
Share

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;
avatar image ValveEr · Jun 02, 2017 at 10:33 PM 0
Share

THANK YOU SO MUCH! This Was Super Helpful and I Will Continue to Use This! THANKS AGAIN!

avatar image schkorpio · Jul 22, 2017 at 05:31 AM 0
Share

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.

avatar image zeday · Sep 06, 2017 at 12:02 AM 1
Share

@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. Many thanks once again!

avatar image CedricMorelFrancoz · Aug 06 at 09:40 AM 0
Share

thanks for the tips, it works

avatar image
0

Answer by PokerBob · Oct 26 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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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

Is it possible to detect which GUIStyleState is used? 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges