Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 Uping · Feb 04, 2014 at 01:38 AM · animationbuttondisableenablepress

how to disable a button after pressing it and enable again after pressing another button

i have a code for a QandA game where in when you pressed attack a gui box with question will appear and if you choose an answer, animation will play, my problem is when the animation play i can still click the attack button and gui will pop up, what i want is when i press the attack button and choose an answer then the animation plays i wont be able to press it again until my animation ends

here's my code

 void DrawInfo() {
             Rect rect = new Rect(500, 100, 400, 200);
             Rect close = new Rect(600, 500, 200, 100);
             if(GUI.Button(close, "ATTACK"))
              
     
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
Best Answer

Answer by Nanobrain · Feb 04, 2014 at 04:58 AM

Try:

 if(!animation.isPlaying()) {
     if(GUI.Button(close, "ATTACK"))
 }

That way your attack button is only displayed if the animation is NOT playing.

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 Uping · Feb 04, 2014 at 06:24 AM 0
Share

hmm im sorry im kinda noob for this but when i put it i get errors can you explain it further if its okay and where should I put it thank you

avatar image Nanobrain · Feb 04, 2014 at 07:24 AM 0
Share
     if(!animation.isPlaying()) {
         if(GUI.Button(close, "ATTAC$$anonymous$$")) {
             Poop = !Poop;
         }
     }


That's where you should put it. Just like that, which is within your DrawInfo() method.

avatar image Uping · Feb 04, 2014 at 07:34 AM 0
Share

okay i got it thank you by the way what if you have two kinds of animation is it right to code it this way

  if(!animation.isPlaying("CORRECT")) {
  if(!animation.isPlaying("Incorrect")) {
         if(GUI.Button(close, "ATTAC$$anonymous$$")) {
             Poop = !Poop;
         }
     }
 }
avatar image Nanobrain · Feb 04, 2014 at 06:35 PM 0
Share

Yep, looks like that will work just fine.

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

19 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

Related Questions

How to disable collision detection while a UI Panel is enabled 2 Answers

Enable/Disable GameObject Button script 1 Answer

Disable/Enable Buttons and Text plz help jc 1 Answer

This should be simple : Input Button Question 1 Answer

How to make animations on button press. 2 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