AlphaTween.cs 986 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class AlphaTween : TweenBase
  5. {
  6. private float[] endAlphas;
  7. private Renderer[] renderers;
  8. protected override void Awake()
  9. {
  10. base.Awake();
  11. renderers = this.GetComponentsInChildren<Renderer>();
  12. endAlphas = new float[renderers.Length];
  13. for (int i = 0; i < renderers.Length; i++)
  14. {
  15. endAlphas[i] = renderers[i].material.color.a;
  16. }
  17. }
  18. public override void Init()
  19. {
  20. base.Init();
  21. for (int i = 0; i < renderers.Length; i++)
  22. {
  23. LeanTween.alpha(renderers[i].gameObject, 0, 0);
  24. }
  25. }
  26. public override void StartAction()
  27. {
  28. if(!this.enabled)
  29. {
  30. return;
  31. }
  32. for (int i = 0; i < renderers.Length; i++)
  33. {
  34. LeanTween.alpha(renderers[i].gameObject, endAlphas[i], duration).setEase(mLeanTweenType);
  35. }
  36. }
  37. }