当前位置:   article > 正文

unity_DoTween Ease 动画效果展示_dotween ease动画

dotween ease动画

源码

 父物体挂 GridLayoutGroup 组件。

  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using DG.Tweening;
  5. using UnityEngine;
  6. public class Test : MonoBehaviour
  7. {
  8. [SerializeField] private Transform parent;
  9. private List<EaseImage> easeImages = new List<EaseImage>();
  10. private void Start()
  11. {
  12. for (int i = 0; i < 27; i++)
  13. {
  14. GameObject go = LoadPrefab("EaseImage");
  15. go.transform.SetParent(parent);
  16. EaseImage test = go.GetComponent<EaseImage>();
  17. easeImages.Add(test);
  18. }
  19. easeImages[0].Set("Flash", Ease.Flash);
  20. easeImages[1].Set("Linear", Ease.Linear);
  21. easeImages[2].Set("Unset", Ease.Unset);
  22. easeImages[3].Set("InBack", Ease.InBack);
  23. easeImages[4].Set("InBounce", Ease.InBounce);
  24. easeImages[5].Set("InCirc", Ease.InCirc);
  25. easeImages[6].Set("InCubic", Ease.InCubic);
  26. easeImages[7].Set("InElastic", Ease.InElastic);
  27. easeImages[8].Set("InExpo", Ease.InExpo);
  28. easeImages[9].Set("InFlash", Ease.InFlash);
  29. easeImages[10].Set("InQuad", Ease.InQuad);
  30. easeImages[11].Set("InQuart", Ease.InQuart);
  31. easeImages[12].Set("InQuint", Ease.InQuint);
  32. easeImages[13].Set("InSine", Ease.InSine);
  33. easeImages[14].Set("OutBack", Ease.OutBack);
  34. easeImages[15].Set("OutBounce", Ease.OutBounce);
  35. easeImages[16].Set("OutCirc", Ease.OutCirc);
  36. easeImages[17].Set("OutCubic", Ease.OutCubic);
  37. easeImages[18].Set("OutElastic", Ease.OutElastic);
  38. easeImages[19].Set("OutExpo", Ease.OutExpo);
  39. easeImages[20].Set("OutFlash", Ease.OutFlash);
  40. easeImages[21].Set("OutQuad", Ease.OutQuad);
  41. easeImages[22].Set("OutQuart", Ease.OutQuart);
  42. easeImages[23].Set("OutQuint", Ease.OutQuint);
  43. easeImages[24].Set("OutSine", Ease.OutSine);
  44. easeImages[25].Set("INTERNAL_Custom", Ease.INTERNAL_Custom);
  45. easeImages[26].Set("INTERNAL_Zero", Ease.INTERNAL_Zero);
  46. }
  47. public static GameObject LoadPrefab(string path)
  48. {
  49. GameObject prefab = null;
  50. prefab = Resources.Load<GameObject>(path);
  51. GameObject go = null;
  52. if (prefab != null)
  53. {
  54. go = Instantiate(prefab);
  55. }
  56. return go;
  57. }
  58. }

 

预制体 EaseImage 放在 Resources 文件夹下面。

  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using DG.Tweening;
  5. using TMPro;
  6. using UnityEngine;
  7. public class EaseImage : MonoBehaviour
  8. {
  9. [SerializeField] private TextMeshProUGUI _text;
  10. [SerializeField] private Transform _imageTrans;
  11. public void Set(string name, Ease ease)
  12. {
  13. _text.text = name;
  14. _imageTrans.localScale = Vector3.zero;
  15. _imageTrans.DOScale(Vector3.one, 3).SetEase(ease).SetLoops(-1);
  16. }
  17. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/125973
推荐阅读
相关标签
  

闽ICP备14008679号