Author Topic: UIPlayAnimation - Check for animation-play before triggering a new animation?  (Read 2687 times)

Raptcha911

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Hey, I'm fairly new to NGUI & ve been using it only for a month or two now. I have separate animations for the In/Out transitions of these panel which I call upon button click. I use UIPlayAnimation to play the animation upon click. Everything works fine, but if I click on two buttons (one ryt after the other) two different animations happen together resulting in my game screen having two panels at once, overlapping each other. My question is, while using UIPlayAnimation to play the animations, Is there a way to check if any animation is playing, before triggering a new animation??

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
If you need some arbitrary condition before playing an animation, then don't use UIPlayAnimation. Write a simple custom script instead.
  1. using UnityEngine;
  2.  
  3. public class PlayMyAnimation : MonoBehaviour
  4. {
  5.     void OnClick ()
  6.     {
  7.         // is the animation already playing? yes? exit.
  8.         // otherwise play the animation.
  9.     }
  10. }