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 /
  • Help Room /
avatar image
0
Question by Riderfan · Jan 03, 2016 at 06:55 PM · buttonscontrollersclicks

Disable UI Button clicks

Hi there. This question seems like a longshot to ask but figured what the heck.

I have a UI Panel with a collection of Button objects on it. The goal is to be able to navigate up and down and click the selected button with only a game controller. There can be multiple controllers attached so only the game controller being 'ListendTo' should operate the panel.

So far, everything is working as designed. I am getting the array of Button objects on the panel, and I can navigate up and down the button group with the correct controller. Any other controller has no navigation effect. In otherwords, Player1 can navigate the buttons, Player2 has no control.

To fire a button click I use;

 if (mLocalInput.ButtonPressed(Submit)) // Executes the Press
             ExecuteEvents.Execute(selectedButton.gameObject, eventSystem, ExecuteEvents.pointerDownHandler); 

'mLocalInput' is the controller being listened to. So far it's working well for the selected controller.

The problem is that the buttons are also still receiving click events from all other devices. Other controllers and the mouse can still fire the click event for the selected button. In otherwords, Player1 can navigate and click buttons, Player2 can't navigate but can still click buttons.

I've come to the conclusion that Buttons have some sort of method of listening to all left Click or 'Submit' button events.

Is there a way to disable the default button click events for buttons?

Hopefully that makes sense. thanks David

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
0

Answer by corn · Jan 04, 2016 at 05:24 PM

Not entirely sure that's what you're looking for, but you can use Button.interactable, set it to false and your button won't be clickable.

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 Riderfan · Jan 04, 2016 at 05:59 PM 0
Share

Thanks, I'd thought of that. Unfortunately that grey's out the button and ignores the ExecuteEvents call.

I need something that will still handle my event calls, but ignores input from any devices other than the device it should be listening to.

avatar image corn Riderfan · Jan 04, 2016 at 08:26 PM 0
Share

How about something like that then ?

 if (mLocalInput.ButtonPressed(Submit))
 { 
     selectedButton.interactable = true;
   // Executes the Press
   ExecuteEvents.Execute(selectedButton.gameObject, eventSystem, ExecuteEvents.pointerDownHandler); 
   selectedButton.interactable = false;
 }

That's kind of a workaround, but only the controller being listened to will be able to click the button.

avatar image Riderfan corn · Jan 04, 2016 at 08:58 PM 0
Share

Not exactly correct, but maybe something to work with. It still greys out the button that's not selected but I might be able to get creative with textures to work around that.

I don't know, Unity's input system seems like it was designed around single player games. As soon as you have more than one controller I seem to be writing a lot of work arounds. The "Re-Wired" component from the Asset Store helps a lot to manage and listen to multiple controllers, but the UI interaction is still a bit of an issue, because the components listen to any device by default. I'm sure there's probably a way to do this.

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

39 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

Related Questions

If Mouse cursor is above an object, start animation (without click on It) 2 Answers

how to make a main menu button 0 Answers

Buttons only work occasionally. 0 Answers

Cannot assign variable agents for clicking a button 0 Answers

after pressing button many times the player starts moving more. 1 Answer


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