| 1234567891011121314151617181920212223242526272829303132 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using DG.Tweening;
- public class TextFadeLoop : MonoBehaviour
- {
- public TextMesh[] uiText; // 拖入你的 Text 组件
- public float duration = 1f;
- public float targetScale = 0.8f;
- void Start()
- {
- // 初始颜色设置(可选)
- Color startColor = uiText[0].color;
- startColor.a = 1f;
- foreach (var item in uiText)
- {
- item.color = startColor;
- // 执行透明度循环
- //item.DOFade(0f, duration) // 变透明
- // .SetLoops(-1, LoopType.Yoyo) // 无限循环,Yoyo表示往返
- // .SetEase(Ease.InOutSine); // 平滑过渡
- item.transform.DOScale(targetScale, duration)
- .SetLoops(-1, LoopType.Yoyo)
- .SetEase(Ease.InOutSine);
- }
-
- }
- }
|