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
0
Question by MaximeS · May 08, 2014 at 06:38 PM · c#animation

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 :)

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

0 Replies

· Add your reply
  • Sort: 

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

20 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

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


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