Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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 Nakor · Jan 28, 2016 at 04:30 PM · uimouseinteractionvisibility

Hide cursor and stop interaction

I have set up a basic dynamic control system. The player can use the mouse and keyboard or controller. When they start using the controller several things happen, but the most relevant thing here is that the mouse is hidden. That works fine. What is wrong is that the mouse still interacts with the UI under it while hidden. How do I stop this from happening?

I'm looking for some sort of setting or something that I'm missing. I certainly can not go through every script and remove raycast target because I need mouse and keyboard control as well. I only want to block mouse interaction when the cursor is hidden.

Using 5.3. Code is in C# but it's just the normal Cursor.visible. I have tried locking the cursor but that is somehow worse as the cursor goes to the center and interacts with everything under the center point.

Thanks.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by LLIV · Jan 28, 2016 at 04:51 PM

Hmmmmm. You could try and do two things here. 1. You could try finding a dead zone and locking the mouse there. 2. You said you hide the mouse whenever the controller is used. I assume this involves some sort of Boolean variable. It might take a while but you could put a if statement in your scripts that says if the controller is being used stop taking input from the mouse. This would stop it from interacting with the scene. thats what I would do but I'm never right! :)

Comment
Add comment · Show 3 · 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 Nakor · Jan 29, 2016 at 04:27 PM 1
Share

Do you know of any way to move the mouse through code? When I search for how to do that it always requires some Windows specific API usage which I can not abide.

Hiding the mouse is as simple as setting -> Cursor.visible = false;

I'm hoping to avoid using the strategy you mentioned. It's a bunch of extra work that shouldn't be necessary. I'm not saying it's a bad idea, I'm just saying that there hopefully is a better solution. If there isn't, Unity should put one in.

I appreciate your thoughts :)

avatar image Nakor · Jan 29, 2016 at 05:37 PM 1
Share

I found a solution. The input system I am using has a simple bool I can set on or off to disable mouse interaction. Thanks for the help.

avatar image Erethan Nakor · Aug 17, 2017 at 05:48 PM 0
Share

@Nakor, Could you expand a little bit more on that? (I have a similar issue)

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.

Follow this Question

Answers Answers and Comments

44 People are following this question.

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

Related Questions

UI mouse click prevent default / stop propagation. (Block mouse events of other scripts) 3 Answers

Native resolution fullscreen breaks UI clicks 0 Answers

How do i disable my buttons while dragging ScrollRect? 0 Answers

Advice for making a 2D Dialogue System? 2 Answers

PauseMenu - Camera moves in pausemenu 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges