CanvasAlphaTween.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. /// <summary>
  5. /// UGUI的Canvas的渐入效果
  6. /// </summary>
  7. public class CanvasAlphaTween : TweenBase
  8. {
  9. //修改Canvas的Alpha值实现
  10. private CanvasGroup[] renderers;
  11. protected override void Awake()
  12. {
  13. base.Awake();
  14. renderers = this.GetComponentsInChildren<CanvasGroup>();
  15. }
  16. public override void Init()
  17. {
  18. base.Init();
  19. for (int i = 0; i < renderers.Length; i++)
  20. {
  21. //LeanTween.alpha(renderers[i].gameObject, 0, 0);
  22. LeanTween.alphaCanvas(renderers[i], 0,0);
  23. }
  24. }
  25. public override void StartAction()
  26. {
  27. if(!this.enabled)
  28. {
  29. return;
  30. }
  31. for (int i = 0; i < renderers.Length; i++)
  32. {
  33. //LeanTween.alpha(renderers[i].gameObject, endAlphas[i], duration).setEase(mLeanTweenType);
  34. LeanTween.alphaCanvas(renderers[i], 1, duration).setEase(mLeanTweenType);
  35. }
  36. }
  37. }