SHARE
TWEET

SpriteAnim Effect Example

Powerhoof Oct 12th, 2016 153 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using UnityEngine;
  2. using System.Collections;
  3. using PowerTools;
  4.  
  5. /// Plays an animation and then destroys itself
  6. [RequireComponent(typeof(SpriteAnim))]
  7. public class Effect : MonoBehaviour
  8. {  
  9.     [SerializeField, Tooltip("The animation to play!")]
  10.     AnimationClip m_animation = null;
  11.  
  12.     SpriteAnim m_spriteAnim = null;
  13.  
  14.     // Use this for initialization
  15.     void Start ()
  16.     {
  17.         // Store the sprite animation component so we don't have to get it again every frame
  18.         m_spriteAnim = GetComponent<SpriteAnim>();
  19.  
  20.         // Play the animation
  21.         m_spriteAnim.Play(m_animation);
  22.     }
  23.    
  24.     // Update is called once per frame
  25.     void Update ()
  26.     {
  27.         // If the animation has finished playing, destroy the object
  28.         if ( m_spriteAnim.IsPlaying() == false )
  29.             Destroy(gameObject);
  30.     }
  31. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top