82 lines
2.0 KiB
C#
82 lines
2.0 KiB
C#
using DG.Tweening;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class Anim : MonoBehaviour
|
|
{
|
|
/// <summary>
|
|
/// 按钮放大倍数
|
|
/// </summary>
|
|
private float scaleMultiplier = 1.2f;
|
|
/// <summary>
|
|
/// 按钮放大缩小的时间
|
|
/// </summary>
|
|
private float scaleUpDuration = 0.2f;
|
|
private float scaleDownDuration = 0.2f;
|
|
/// <summary>
|
|
/// 按钮本身的缩放倍数
|
|
/// </summary>
|
|
private Vector3 originalScale;
|
|
/// <summary>
|
|
/// 按钮动画响应时间
|
|
/// </summary>
|
|
public int BTntimer = 500;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
/// <summary>
|
|
/// 按钮
|
|
/// </summary>
|
|
/// <param name="ob"></param>
|
|
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()
|
|
{
|
|
|
|
}
|
|
}
|