using DG.Tweening; using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; using UnityEngine; using UnityEngine.UI; public class Anim : MonoBehaviour { /// /// 按钮放大倍数 /// private float scaleMultiplier = 1.2f; /// /// 按钮放大缩小的时间 /// private float scaleUpDuration = 0.2f; private float scaleDownDuration = 0.2f; /// /// 按钮本身的缩放倍数 /// private Vector3 originalScale; /// /// 按钮动画响应时间 /// public int BTntimer = 500; // Start is called before the first frame update void Start() { } /// /// 按钮 /// /// public void BTnmove(GameObject ob) { originalScale = transform.localScale; ob.transform.DOScale(ob.transform.localScale * scaleMultiplier, scaleUpDuration) .OnComplete(() => { ob.transform.DOScale(originalScale, scaleDownDuration); }); Task.Delay(BTntimer); } public void ShowPanel(GameObject panel) { if (panel == null) { Debug.Log("panel==null"); return; } panel.SetActive(true); panel.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); panel.transform.DOScale(1f, 0.5f); } public void HidePanel(GameObject panel, bool isdes) { panel.transform.DOScale(0.5f, 0.5f); if (isdes) { Destroy(panel); } else { panel.SetActive(false); } } public void MoveToOriginBy(GameObject target) { Vector3 currentPosition = target.transform.position; target.transform.DOMove(new Vector3(540, 960, 0), 0.5f); // 使用 DOMove 直接移动到原点 } // Update is called once per frame void Update() { } }