Eonirr

Untitled

Feb 13th, 2026
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. using Spine.Unity;
  2. using UnityEngine;
  3. using System.Collections;
  4.  
  5. public class SpineHitFlash : MonoBehaviour
  6. {
  7. public SkeletonAnimation skeleton;
  8. private Color originalColor;
  9.  
  10. void Awake()
  11. {
  12. originalColor = skeleton.skeleton.GetColor();
  13. }
  14.  
  15. public void PlayHitFlash(float duration = 0.08f)
  16. {
  17. StartCoroutine(FlashRoutine(duration));
  18. }
  19.  
  20. private IEnumerator FlashRoutine(float duration)
  21. {
  22. if (!skeleton) yield break;
  23.  
  24. skeleton.skeleton.SetColor(Color.white);
  25. skeleton.UpdateWorldTransform();
  26.  
  27. float t = 0f;
  28. while (t < duration)
  29. {
  30. t += Time.deltaTime;
  31. yield return null;
  32. }
  33.  
  34. skeleton.skeleton.SetColor(originalColor);
  35. skeleton.UpdateWorldTransform();
  36. }
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment