Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Spine.Unity;
- using UnityEngine;
- using System.Collections;
- public class SpineHitFlash : MonoBehaviour
- {
- public SkeletonAnimation skeleton;
- private Color originalColor;
- void Awake()
- {
- originalColor = skeleton.skeleton.GetColor();
- }
- public void PlayHitFlash(float duration = 0.08f)
- {
- StartCoroutine(FlashRoutine(duration));
- }
- private IEnumerator FlashRoutine(float duration)
- {
- if (!skeleton) yield break;
- skeleton.skeleton.SetColor(Color.white);
- skeleton.UpdateWorldTransform();
- float t = 0f;
- while (t < duration)
- {
- t += Time.deltaTime;
- yield return null;
- }
- skeleton.skeleton.SetColor(originalColor);
- skeleton.UpdateWorldTransform();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment