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 /
This question was closed Mar 10, 2019 at 10:42 AM by Bunny83 for the following reason:

The question is answered, right answer was accepted

avatar image
14
Question by dreyescairo · Dec 21, 2014 at 10:03 AM · uibuttonpausing

Button is being triggered by spacebar after clicked once

I have a pause button in my space shooter game. When I pause, then un-pause, every time I use the space bar to shoot, it triggers the pause button. Is this because the pause button stays focused after being pressed once? Is it possible to un focus the button? I am using unity's 4.6 GUI system.

Pause button code:

     `public void pause(){
        if (Time.timeScale == 1) {
           Time.timeScale = 0;
           pauseText.enabled = true;
           mainMenuBT.gameObject.SetActive(true);

             } else {
           Time.timeScale = 1;
           pauseText.enabled = false;
           mainMenuBT.gameObject.SetActive(false);
             }
     }`

Any help in the right direction would be very much appreciated.

Comment
Comments Locked
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

  • Sort: 
avatar image
87
Best Answer

Answer by Kyle_WG · Jun 09, 2015 at 04:21 PM

Sorry if irrelevant to you now but I thought I'd add for anyone else that comes across like me.

You can set the Navigation part of the UI.Button to None so it doesn't keep focus. It acts like a form so you can easily navigate from one UI element to another (like when you tab to other fields etc.) Mine was defaulted to automatic.

Unity version 5.0.0b18.

alt text


navi.png (15.5 kB)
Comment
Comments Locked · Show 7 · 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 drHogan · Sep 15, 2015 at 09:05 AM 2
Share

I had the same problem and your solution was perfect. Cheers $$anonymous$$yle!

avatar image Kyle_WG drHogan · Sep 15, 2015 at 09:21 AM 0
Share

Excellent :)

avatar image jektal0 · Oct 05, 2015 at 06:42 PM 3
Share

Thanks! In my scenario, after clicking a button once the next click anywhere would trigger it again. Changing Navigation to None has fixed that and made it only fire when clicked!

avatar image Kyle_WG jektal0 · Oct 06, 2015 at 09:27 AM 0
Share

Great! Really surprised that it uses Automatic by default. Glad it helped.

avatar image brayhanreye · Feb 16, 2017 at 01:20 AM 2
Share

Thanks $$anonymous$$yle, that was simple and helpful.

avatar image mikewilliams76901 · May 16, 2017 at 03:57 PM 1
Share

You are my hero.

avatar image plszhao · Mar 10, 2019 at 09:58 AM 1
Share

Thank you very much!

avatar image
0

Answer by kevinspawner · Dec 22, 2014 at 10:39 AM

You need to create a bool and to trigger the pause on and off when required. Currently you are just scaling the time scale 1 and 0. You need to create a private or public bool and then enable and disable it to trigger the pause function. Hope it helps.

Comment
Comments Locked · Show 2 · 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 dreyescairo · Dec 24, 2014 at 07:11 AM 1
Share

Thanks for the reply. I actually just got it to work. Turns out that space bar was an alternate positive in the Input $$anonymous$$anager for the button. I had to go to Edit > Project Settings > Input. Then under Submit, I reassigned the Alt Positive Button to something other than the space bar. I can now Pause then un-pause and shoot with the space bar without accidentally triggering the pause button every time.

avatar image kevinspawner · Mar 12, 2015 at 04:12 AM 0
Share

Cool. Glad you got it working.

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

Can't get 4.6 GUI Button to Load Scene (Solved) 1 Answer

Launching an animation with new GUI in Unity 4.6 1 Answer

(4.6 UI) Button is highlighted permanently 3 Answers

How do I reset GUI Button to normal state texture(Android)? 0 Answers

How to create a button for every supported resolution? 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