2024-11-13 21:45:48 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
2024-11-14 18:11:08 +08:00
|
|
|
|
using DG.Tweening;
|
2024-11-13 21:45:48 +08:00
|
|
|
|
public class Tools : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public static IEnumerator AnimateText(float startValue, float endValue, float time, Text SetText)
|
|
|
|
|
{
|
|
|
|
|
float elapsedTime = 0f; // <20>Ѿ<EFBFBD><D1BE><EFBFBD>ȥ<EFBFBD><C8A5>ʱ<EFBFBD><CAB1>
|
|
|
|
|
while (elapsedTime < time)
|
|
|
|
|
{
|
|
|
|
|
elapsedTime += Time.deltaTime;
|
|
|
|
|
float t = elapsedTime / time;
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>㵱ǰֵ<C7B0><D6B5>ʹ<EFBFBD><CAB9> Mathf.Lerp <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Բ<EFBFBD>ֵ
|
|
|
|
|
int currentValue = Mathf.RoundToInt(Mathf.Lerp(startValue, endValue, t));
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>ʾ
|
|
|
|
|
SetText.text = currentValue.ToString();
|
|
|
|
|
|
|
|
|
|
yield return null; // <20>ȴ<EFBFBD>һ֡
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SetText.text = endValue.ToString();
|
|
|
|
|
|
|
|
|
|
}
|
2024-11-14 18:11:08 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//public static void MoveUpOrDwon(RectTransform obj,float add)//<2F><><EFBFBD>ϻ<EFBFBD><CFBB><EFBFBD><EFBFBD>ƶ<EFBFBD>
|
|
|
|
|
//{
|
|
|
|
|
// float targetY = obj.anchoredPosition.y + add; // <20><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>λ<EFBFBD><CEBB>
|
|
|
|
|
// obj.DOAnchorPosY(targetY, 1f).SetEase(Ease.Linear);
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
public static void MoveUpOrDwon(RectTransform obj, float add, System.Action onComplete = null)
|
2024-11-13 21:45:48 +08:00
|
|
|
|
{
|
2024-11-14 18:11:08 +08:00
|
|
|
|
float targetY = obj.anchoredPosition.y + add; // <20><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>λ<EFBFBD><CEBB>
|
|
|
|
|
obj.DOAnchorPosY(targetY, 1f).SetEase(Ease.Linear).OnComplete(() => {
|
|
|
|
|
|
|
|
|
|
if (onComplete != null)
|
|
|
|
|
{
|
|
|
|
|
onComplete.Invoke();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
2024-11-13 21:45:48 +08:00
|
|
|
|
|
|
|
|
|
}
|
2024-11-14 18:11:08 +08:00
|
|
|
|
|
2024-11-13 21:45:48 +08:00
|
|
|
|
}
|