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 /
avatar image
1
Question by Omar47i · Nov 22, 2016 at 01:19 PM · animationanimatoranimationstate

Animation messed up when object deactivates?

Hi everyone, I have a button with animator component and four animations (Disabled, Highlighted, Normal and Pressed). When i press on the button i deactivate the panel containing this button and activate a new panel, what happens is simply the button scaled down on press event, now when i reactivate the pannel containing this button the scale won't return back to normal scale which is Normal animation state!.

I know that problem happens when i deactivate the object containing the animation while it is playing (It won't return to normal state). Does anyone know how to solve this issue, any solution or even hackaround is appreciated.

Thanks all.

Comment
Add comment · Show 4
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 hexagonius · Nov 22, 2016 at 09:25 PM 0
Share

check the animations for the 'write defaults' toggle and check it

avatar image Omar47i hexagonius · Nov 24, 2016 at 11:22 AM 0
Share

It's checked by default!

avatar image Omar47i hexagonius · Nov 24, 2016 at 11:24 AM 0
Share

Actually there some workarounds to this issue like make a script on the animation and implement the initial state in OnDisable() or disable the renderer of the gameObject until animation finishes then disable the gameObject, But i really don't think that it's a good idea to always use this technique to solve the issue, Please suggest any solution if you can.

avatar image hexagonius Omar47i · Nov 24, 2016 at 11:59 PM 0
Share

what does the animator say? is it in the right state (open animator Rosie and select the button)? does the state control the scale?
from my today's experience, every animation controlled value is not even changeable manually so if both your answers are yes, I don't know, I check on it tomorrow :)

1 Reply

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

Answer by Omar47i · Nov 28, 2016 at 02:08 PM

Ok i think i found a work around, i can't consider it a solution but it did what i want. First to prevent the unexpected animation behaviour i made a coroutine to wait for a specific amount of time before disabling the gameObject containing the animation say .18f seconds to ensure that it doesn't interrupt the transition between states, While it works well if the user tapped quickly on the button within the waiting time (.18f) then the same bad behaviour occurs again, so i solved it using this code:

     // to indicate if we currently in an animation
     private bool inAnim = false;
 
     public void onPlayButton()
     {
         if (!inAnim)
         {
             // disable collider on the button to prevent unexpected behaviour
             m_PlayButton.GetComponent<Image>().raycastTarget = false;
 
             inAnim = true;
             StartCoroutine(onPlayDelayed());
         }
     }
 
     private IEnumerator onPlayButtonDelayed()
     {
         yield return new WaitForSeconds(.18f);
         next_UI_Panel.SetActive(true);
         current_UI_Panel.SetActive(false);
 
         // enable collider on the button again
         m_PlayButton.GetComponent<Image>().raycastTarget = true;
         inAnim = false;
     }

Hope that help you guys. thanks.

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

127 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

There are anything equlient for AnimationState in Animator? 0 Answers

Why does this animator appear to occupy two states, but report only one? 0 Answers

2D Animation does not start 1 Answer

Accessing AnimationState in Animator 0 Answers

Toggling between states of animation 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