playMaker

Author Topic: 2d toolkit pause animation  (Read 1606 times)

msc4tech

  • Playmaker Newbie
  • *
  • Posts: 17
    • View Profile
    • http://www.msc4tech.com
2d toolkit pause animation
« on: December 06, 2011, 03:13:28 AM »
using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
   [ActionCategory("2D Toolkit")]
   [Tooltip("Pause a sprite animation on a tk2dAnimatedSprite")]
   public class Pause2dToolkitAnim : FsmStateAction {
      [RequiredField]
      public FsmOwnerDefault gameObject;   
      
      
      private GameObject go;
      private tk2dAnimatedSprite spriteAnim;
      
      public override void Reset() {
         gameObject = null;
      }
      
      public override void OnEnter() {
         go = gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value;
         spriteAnim = go.GetComponent<tk2dAnimatedSprite>();
         if (spriteAnim.isPlaying()==true)
         {
            spriteAnim.Pause();
         }
         Finish();
      }
   }
   
}