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
2
Question by Anymeese · Jan 17, 2015 at 07:12 PM · animationuibuttonanimatortransition

Animator has not been initialized??

I've been working on a Client type of UI. The buttons all have transition type Animation, with an attached animator. When buttons are disabled, they scale down. When enabled, they return to (or just are) normal scale. For some reason, when I run my function to reset everything, I sometimes get the error "Animator not Initialized" and sometimes dont, but the transition animations just stop playing. I'm 100% sure I'm not setting the animator null anywhere in the code, and I've tried button.interactable = true, button.animator.SetTrigger("Normal"), and button.GetComponent().SetTrigger("Normal"). The buttons stay scaled down (but ARE interactable again)

What's happening?

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 xxBarginsxx · Jan 18, 2015 at 06:19 PM 0
Share

Can you link some code please? It's much easier to find problems if you like the problem code :)

avatar image Anymeese · Jan 18, 2015 at 06:32 PM 0
Share

$$anonymous$$y code is split up between 5 big scripts (and a bunch of tiny ones) :/ I was hoping this would be a common error that people might know the cause of

3 Replies

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

Answer by Julien-Lynge · Feb 03, 2015 at 05:29 PM

When the GameObject containing an animator is turned on, the animator starts uninitialized, and is initialized that frame. If you attempt to call methods on the animator in the same frame it's being initialized, the call may go through before the initialization finishes, and Unity will refuse to run the command. The transition won't occur because you never actually set the trigger. The solution would be to wait a frame after turning on the object, and then call your method.

I believe that the initialization happens each time the GameObject is activated, not just the first time. As an alternative to waiting a frame, you could try LateUpdate or yield return new WaitForEndOfFrame().

Comment
Add comment · 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 vitorlanna · Mar 18, 2015 at 07:16 PM 0
Share

Thank you so much! I was going crazy over this.

avatar image ThomLaurent · Nov 24, 2016 at 03:06 PM 0
Share

WaitForEndOfFrame() sometime isn't enough for the animator to be ready (initialized), your best bet is to yield return new WaitUntil(() => animator.isInitialized);

avatar image
2

Answer by RJ45 · Aug 04, 2016 at 05:05 AM

Put it in a coroutine and wait until the animation isInitialized flag is true.

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 ThomLaurent · Nov 24, 2016 at 03:04 PM 0
Share

i.e : yield return new WaitUntil( () => animator.isInitialized ); Thanks for the tip :)

avatar image
0

Answer by ndcv · Mar 17, 2015 at 09:15 PM

I was having this same problem and this thread helped me track it down...

I have a CanvasGroup holding my three buttons. The CanvasGroup had interactable set to "false" and alpha to zero, so the menu wouldn't be there on load. The Buttons are using Animation transitions, and the CanvasGroup has an animator to fade the whole menu in and out.

My workaround/solution so far is to leave the CanvasGroup interactable = true, but the default animation state is one that sets it to false. The warnings are completely gone now.

Down side is, I think that there now might be some amount of time (hopefully only one frame) at load when the invisible buttons are interactable. Not sure if that will cause any problems or not.

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

30 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

Related Questions

Button animation (transition) reset 0 Answers

UI button pressed animation not playing directly after entering 2 Answers

How to change UI button animation speed (4.6 UI) 2 Answers

How to have both a button entry animation and a highlight animation 0 Answers

How do I play an animation once on button click? 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