- Home /
animation.isPlaying always true and Animation stuck at time 0
Hello guys,
I stumbled upon an animation problem today and i'm all out of solutions, so now i'm asking for help.
Basicly, i'm calling animation.Play, and the "isPlaying" flag is set to true but the animation never start and never set "isPlaying" back to false
so here is my code :
using UnityEngine; using System; using System.Collections; using System.Collections.Generic; public class RewardIconPanel : MonoBehaviour { public delegate void AnimationCompleteHandler(); public UILabel mValueLabel; public UISprite mIconSprite = null; public AK.ENUMERATOR.EVENTS mFeedbackSoundName = AK.ENUMERATOR.EVENTS.NONE; public Animation mFXAnimation = null; public List<ParticleSystem> mFXParticles = new List<ParticleSystem>(); public event AnimationCompleteHandler OnAnimationCompleted; private bool isStarted = false; [SerializeField] private string mPopAnimName = ""; [SerializeField] private string mUnpopAnimName = ""; [SerializeField] Animation mAnimation = null; const string AmountPrefix = "+"; public void Start() { if (mFXAnimation != null) { mFXAnimation.wrapMode = WrapMode.Once; } } public void Show() { mAnimation.Play(mPopAnimName); isStarted = true; } public void Hide() { mAnimation.Play(mUnpopAnimName); isStarted = true; } void Update() { if(Input.GetKeyDown(KeyCode.A)) mAnimation.Play(mPopAnimName); if(isStarted && !mAnimation.isPlaying) { if(OnAnimationCompleted != null) OnAnimationCompleted(); isStarted = false; } } public virtual void SetValue( string spriteName, string value ) { mValueLabel.text = AmountPrefix+value; UIAtlasRef.SetSprite( spriteName, mIconSprite ); mIconSprite.MakePixelPerfect(); } public virtual void SetValueAndScale(string spriteName, string value, float scaleDestination) { /*mValueLabel.text = AmountPrefix+value; UIAtlasRef.SetSprite( spriteName, mIconSprite ); mIconSprite.MakePixelPerfect(); mIconSprite.transform.localScale /= scaleDestination;*/ } public void SetText( string value ) { mValueLabel.text = value; } public void PlayFeedbackSound() { //if (!String.IsNullOrEmpty(mFeedbackSoundName)) //{ // AudioManager.PlayOneShotSFX(mFeedbackSoundName); //} if ( mFeedbackSoundName != AK.ENUMERATOR.EVENTS.NONE ) SoundEngine.Instance.PostEvent( AK.ENUMERATOR.EVENTS_ID[mFeedbackSoundName] ); } public void PlayFeedbackFX() { if (mFXAnimation != null) { mFXAnimation.wrapMode = WrapMode.Once; mFXAnimation.Play(); } if (mFXParticles != null) { foreach(ParticleSystem system in mFXParticles) { if(system != null) system.Play(); } } } }
So I have a GameObject with an animation component and this script. my animation are set to default wrapmode and the animations are scale up/ scale down.
the GameObject is instantiate just before I call Hide on it and is set active by default.
You can see that I play the animation when I press "A", it is also not working.
However, when I set the animation component on "Play Automatically" it work, also, when it start to play and I call Hide(), the animation play, then restart and complete.
animation.time stay at zero but isPlaying is true
I have recreate the game object again from nothing just to be sure it wasn't a meta bug.
thnx for reading, if you have any potential solution, please post :)
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
C# scriping help 0 Answers
Animation Problem 2 Answers
c# how to get to idle from walk 0 Answers
My weapon takes damage. help... 1 Answer