Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
0
Question by holdingjupiter · Jan 19, 2015 at 04:20 PM · uieventsystemselectablesubmit

keyboard submit not working on selectables.

Not sure if there is much more to say or what from my project I should include. I've built a monitor screen in my game and clicking is fine, I can navigate the options on the screen but pressing return/enter or space is having no effect on the selectables whatsoever. Tried a few things including downloading the latest unity patch (the even system is set to submit | submit, before you ask) I haven't set it to do anything but the buttons are set on color transition and they never change to the pressed color unless I click the trackpad on it. I feel like there must be some small thing that's missing. The components are a screen sized image to mimic a computer and then text objects on them (4). Each text object has a selectable component attached. How do I get submit to be logged and get it to cause the pressed transition?

Comment
Add comment · Show 2
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 spiceboy9994 · Jan 19, 2015 at 06:59 PM 0
Share

Have you check the Navigation property?. As far as I know the Navigation is intended to set the order on how the controls within the scene may "switch focus", something like a web form does. I don't have too much experience on moving that property, but that's something that you may want to check.

Regards

avatar image holdingjupiter · Jan 19, 2015 at 07:55 PM 0
Share

it's set to automatic, the arrow keys/ wasd select the different text ui's, but return (which is called "submit" by unity's input manager) does nothing. Thanks for trying though.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Cliffinho · Mar 16, 2017 at 07:09 AM

I have the same problem, i guess that the Selectable class/component don't have any method to say to itself that he was selected (Unity Script API - Selectable Class), when the button was pressed, so the functionallity of click/press only works with mouse. But i solve my problem with a "simple" script:

 public class MenuSelectableOption : MonoBehaviour, ISelectHandler, IDeselectHandler
 {
     public GameObject targetController;
     public string methodToCall;
     public float delayToCall;
 
     private Selectable mySelectable;
     private bool isSelected;
 
     private void Start()
     {
         mySelectable = GetComponent<Selectable>();
     }
 
     public void OnSelect(BaseEventData eventData)
     {
         isSelected = true;
     }
 
     public void OnDeselect(BaseEventData eventData)
     {
         isSelected = false;
     }
 
     private void Update()
     {
         if (Input.GetKeyDown(KeyCode.Return) && isSelected)
         {
             mySelectable.animator.SetTrigger("Pressed");
             Invoke("CallMethodAction", delayToCall);
         }
     }
 
     private void CallMethodAction()
     {
         targetController.SendMessage(methodToCall);
     }
 }

The "tagetController" is any gameobject in scene which has some script controlling the actions for each option. When users have selected the option and press "return", this script send a message to "targetController", calling the method that will execute the actions. As you can see, i implement the same interfaces (2 only) that Selectable class implements, and i use this to know when the selectable is selected. That solved my problem, although I do not think we should have to do that, because it should work with the keyboard. I really do not know what the problem is, I do not know why it only works with the mouse and not with the keyboard...

[EDIT] I wrote this script because I am making a menu with Texts, and as we have said, the Selectable Component does not detect keyboard input for actions as pressed. But I tested with buttons and it worked, I made a menu with several buttons, and in the gameobject "EventSystem", in the component of the same name, in a property called "First Selected" I put a button whatsoever, and when I tested I saw that when pressing The keys set as submit in the Input Manager, it accepted and executed the pressing actions. No need to write another script or anything else. So, I think if you want to do something like me, but without using buttons, and get the functionality expected only with the keyboard, not the mouse, you should use buttons instead of whatever you're using. In my case, I was trying to use plain Texts by adding the Selectable component, which did not work with the keyboard input. However, buttons worked, so I simply deactivated the Image component of the buttons and left only Text, so the text-only menu works as expected, receiving the Submit of the keys configured in the Input Manager.

(Sorry for bad english, i hop you understand :D)

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.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Selecting a selectable using script doesn't seem to work anymore? 1 Answer

NullReferenceException after passing InputField gameObject into EventSystem.SetSelectedGameObject() 1 Answer

How do I de-highlight a UI Selectable after disabling mouse input? 2 Answers

Overlapping scroll view control. 0 Answers

Is it wise to add scripts to Unity's Event System? 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