Powerhoof

SpriteAnim Effect Example

Oct 12th, 2016
224
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

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×