wuxianshengcong/Assets/Scripts/Anim.cs

82 lines
2.0 KiB
C#
Raw Normal View History

2024-12-30 10:39:09 +08:00
using DG.Tweening;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
public class Anim : MonoBehaviour
{
/// <summary>
/// <20><>ť<EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
private float scaleMultiplier = 1.2f;
/// <summary>
/// <20><>ť<EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD>С<EFBFBD><D0A1>ʱ<EFBFBD><CAB1>
/// </summary>
private float scaleUpDuration = 0.2f;
private float scaleDownDuration = 0.2f;
/// <summary>
/// <20><>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ű<EFBFBD><C5B1><EFBFBD>
/// </summary>
private Vector3 originalScale;
/// <summary>
/// <20><>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧʱ<D3A6><CAB1>
/// </summary>
public int BTntimer = 500;
// Start is called before the first frame update
void Start()
{
}
/// <summary>
/// <20><>ť
/// </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); // ʹ<><CAB9> DOMove ֱ<><D6B1><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD>ԭ<EFBFBD><D4AD>
}
// Update is called once per frame
void Update()
{
}
}