赞
踩
父物体挂 GridLayoutGroup 组件。
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using DG.Tweening;
- using UnityEngine;
-
- public class Test : MonoBehaviour
- {
- [SerializeField] private Transform parent;
-
- private List<EaseImage> easeImages = new List<EaseImage>();
-
- private void Start()
- {
- for (int i = 0; i < 27; i++)
- {
- GameObject go = LoadPrefab("EaseImage");
- go.transform.SetParent(parent);
- EaseImage test = go.GetComponent<EaseImage>();
- easeImages.Add(test);
- }
-
- easeImages[0].Set("Flash", Ease.Flash);
- easeImages[1].Set("Linear", Ease.Linear);
- easeImages[2].Set("Unset", Ease.Unset);
- easeImages[3].Set("InBack", Ease.InBack);
- easeImages[4].Set("InBounce", Ease.InBounce);
- easeImages[5].Set("InCirc", Ease.InCirc);
- easeImages[6].Set("InCubic", Ease.InCubic);
- easeImages[7].Set("InElastic", Ease.InElastic);
- easeImages[8].Set("InExpo", Ease.InExpo);
- easeImages[9].Set("InFlash", Ease.InFlash);
- easeImages[10].Set("InQuad", Ease.InQuad);
- easeImages[11].Set("InQuart", Ease.InQuart);
- easeImages[12].Set("InQuint", Ease.InQuint);
- easeImages[13].Set("InSine", Ease.InSine);
- easeImages[14].Set("OutBack", Ease.OutBack);
- easeImages[15].Set("OutBounce", Ease.OutBounce);
- easeImages[16].Set("OutCirc", Ease.OutCirc);
- easeImages[17].Set("OutCubic", Ease.OutCubic);
- easeImages[18].Set("OutElastic", Ease.OutElastic);
- easeImages[19].Set("OutExpo", Ease.OutExpo);
- easeImages[20].Set("OutFlash", Ease.OutFlash);
- easeImages[21].Set("OutQuad", Ease.OutQuad);
- easeImages[22].Set("OutQuart", Ease.OutQuart);
- easeImages[23].Set("OutQuint", Ease.OutQuint);
- easeImages[24].Set("OutSine", Ease.OutSine);
- easeImages[25].Set("INTERNAL_Custom", Ease.INTERNAL_Custom);
- easeImages[26].Set("INTERNAL_Zero", Ease.INTERNAL_Zero);
- }
-
-
- public static GameObject LoadPrefab(string path)
- {
- GameObject prefab = null;
- prefab = Resources.Load<GameObject>(path);
- GameObject go = null;
- if (prefab != null)
- {
- go = Instantiate(prefab);
- }
-
- return go;
- }
- }
预制体 EaseImage 放在 Resources 文件夹下面。
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using DG.Tweening;
- using TMPro;
- using UnityEngine;
-
- public class EaseImage : MonoBehaviour
- {
- [SerializeField] private TextMeshProUGUI _text;
- [SerializeField] private Transform _imageTrans;
-
- public void Set(string name, Ease ease)
- {
- _text.text = name;
- _imageTrans.localScale = Vector3.zero;
- _imageTrans.DOScale(Vector3.one, 3).SetEase(ease).SetLoops(-1);
- }
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。