Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using PowerTools;
- /// Plays an animation and then destroys itself
- [RequireComponent(typeof(SpriteAnim))]
- public class Effect : MonoBehaviour
- {
- [SerializeField, Tooltip("The animation to play!")]
- AnimationClip m_animation = null;
- SpriteAnim m_spriteAnim = null;
- // Use this for initialization
- void Start ()
- {
- // Store the sprite animation component so we don't have to get it again every frame
- m_spriteAnim = GetComponent<SpriteAnim>();
- // Play the animation
- m_spriteAnim.Play(m_animation);
- }
- // Update is called once per frame
- void Update ()
- {
- // If the animation has finished playing, destroy the object
- if ( m_spriteAnim.IsPlaying() == false )
- Destroy(gameObject);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement