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
1
Question by JtheSpaceC · Nov 28, 2014 at 01:22 PM · uibuttoneventsystem4.6spacebar

4.6 UI Change what 'Spacebar' is doing by default

Hi. So I'm making a game-speed clock for a strategy game (think like Xcom or Empire At War) with 4 buttons on it, and I'm using the new Unity 4.6 UI system with 4 buttons. Each one adjusts the timescale of the game to 0, 1, 10, and 100. See below:

alt text

Clicking the buttons works fine, but the EventSystem (I think, but I don't adequately understand it) seems to do what it likes with the spacebar; namely, it will 'click' the last button that I mouse-clicked on. I want to use the spacebar to always alternate between hitting the Pause button and the X1 button, but I can't. To get around this for now I've set the 'left ctrl' ("Dodge" in my input controls, see script below) button to activate these buttons, but I really want to just stop the spacebar doing its own thing so I can use it myself. Any ideas? Here's the script I'm using but I want to get rid of "Dodge" and use "Jump"(default spacebar button).

         //FOR SPACEBAR PAUSING OR X1 SPEED
         if(Input.GetButtonDown("Dodge"))
         {
             paused = !paused;
 
             if(paused)
             AdjustTimeScale(0);
             else if(!paused)
                 AdjustTimeScale(1);
         }

Note that hitting "Dodge" button calls a function 'void AdjustTimeScale(float timeScale)'. Clicking the UI buttons calls the same function with their respective timeScale floats. Hitting "Dodge" does NOT activate a button click directly, though I've no objection to doing that if the solution requires it. I'm just not sure how to make the key translate to a button click so I made the key go straight to the function.

Thanks Kevin

PS I removed all the "jump" (spacebar) inputs from the Input controls but this had no effect.

x4 buttons.png (23.3 kB)
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

3 Replies

· Add your reply
  • Sort: 
avatar image
9
Best Answer

Answer by Kiwasi · Nov 28, 2014 at 07:11 PM

Go to Edit -> Project Settings -> Input.

In the inspector drop down to submit.

Remove space from the alt positive button.

alt text


delete.png (22.1 kB)
Comment
Add comment · Show 1 · 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 JtheSpaceC · Nov 29, 2014 at 11:54 PM 0
Share

There it is! Thanks.

avatar image
2

Answer by RudyTheDev · Nov 29, 2014 at 03:28 PM

See BoredMormon's answer. It's this option (see image) that uses whatever project input settings define for "submit" key. In this case, (alt) key is space bar.

this option


36009-eventinspector.png (15.9 kB)
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
avatar image
0

Answer by RudyTheDev · Nov 28, 2014 at 01:27 PM

The event system adds another input to Unity inputs that does the default "click" on the currently focused control. I believe it is the default keyboard input module that defines which key does this. Both components should be under the automatically created EventSystem game object.

Comment
Add comment · Show 4 · 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 JtheSpaceC · Nov 28, 2014 at 05:01 PM 0
Share

The scripts for input are on the event system, yes, but I can't open them. Are you meant to be able to?

avatar image RudyTheDev · Nov 28, 2014 at 07:05 PM 0
Share

No, they are Unity's components, not $$anonymous$$onoBehaviour scripts. Your project input settings should have an input (besides jump or whatever) used by whatever input module is eating the space bar.

avatar image JtheSpaceC · Nov 28, 2014 at 07:34 PM 0
Share

Here's the Inspector for my Event System (I've done nothing to it). alt text

Sorry for my poor circling there but I was pointing to the two "Scripts". I can't open them though. If I double click, $$anonymous$$onoDevelop opens, but only on my last open script. It won't open the new one(s).

I see the 'Submit' field there also but submit is set up as 'enter' and another one as 'return' in the Input manager, but nothing has spacebar on it.

Still at a loss..

eventinspector.png (43.9 kB)
avatar image JtheSpaceC · Nov 29, 2014 at 05:10 PM 0
Share

Ah, thanks very much $$anonymous$$ormon and $$anonymous$$!

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

Unity UI Button states 1 Answer

Can't change UI Button Listeners 1 Answer

How to set UI button as selected on mouse over 1 Answer

[4.6 b20] How to make a hold button for the new UI 4 Answers

UI button always selected? 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