- Home /
Animation not playing on game object activated by script
So I have a game object attached to a button on a panel in a canvas, and that panel is activated by pressing a key in game. The animation for that game object doesn't play when the panel is activated in game, but if I have the panel activate when the game starts it plays fine. Why would the animation be messed up by this?
Answer by Masterio · Jul 23, 2017 at 02:38 PM
You need to edit an animation frames in Animation window [first select an animation object]. It is because You want to animate the Image component and animation is attached to the SpriteRenderer component.
I'm not sure what you mean? I have the animation frames set up in the window and attached to an animation object, and it plays correctly when the panel is already active. Do I need to add a SpriteRenderer component to the animation object?
paste an animator window screen and inspector screen on this object, maybe this will tell us something more
Answer by ShadyProductions · Jul 23, 2017 at 02:05 AM
I'm thinking that the panel is disabled when you start the game,
so no scripts on it are loaded which is default behaviour.
This way it cannot register your keystroke.
You will have to seperate the script from the deactivated object.
The keystroke is working fine, it's just that the animation gets stuck on the first frame. I've tried also having the panel start out active and then be deactivated on start, but still gets stuck on that frame.
Answer by Terko · Aug 23, 2017 at 07:31 PM
It looks like you are trying to make a panel manager. There is an asset called Woo Panels. It is a professional solutions. It does all the animations and even more! Check it out! Here is the forum thread.
Your answer
Follow this Question
Related Questions
Why doesn't my UI cover fullscreen on android? 0 Answers
UI Animation Not Playing 1 Answer
Unity Animation performance massive drop 1 Answer
Panels and CanvasGroup in UI management 0 Answers
Animating a Panel,Animating a panel 1 Answer