using DG.Tweening;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class NewBehaviourScript : MonoBehaviour
{
int number;
private Button Close_Btn;
void Start()
{
number = 1;
FormAniimation(true, Test);
Close_Btn = this.transform.Find("bg/Close_Btn").GetComponent<Button>();
Close_Btn.onClick.AddListener(()=>
{
FormAniimation(false, Test);
});
}
public void Test()
{
Debug.Log("结束方法");
}
// Update is called once per frame
void Update()
{
}
public void FormAniimation(bool isShow,Action ac)
{
Vector3 Temp = Vector3.zero;
Vector3 startScale = Vector3.zero;
Vector3 endScale = Vector3.zero;
Vector3 startPos = Vector3.zero;
Vector3 endPos = Vector3.zero;
switch (number)
{
case 0:
break;
case 1:
_= isShow ? endScale = Vector3.one:startScale = Vector3.one ;
break;
case 2:
_= isShow ? startPos = new Vector3(-2500, 0) : endPos = new Vector3(-2500, 0);
break;
case 3:
_= isShow ? endScale = Vector3.one : startScale = Vector3.one;
_= isShow ? startPos = new Vector3(465, -336.5f) : endPos = new Vector3(465, -336.5f);
break;
}
Sequence seq = DOTween.Sequence();
if (startScale!=endScale)
{
transform.localScale = startScale;
seq.Insert(0f,transform.DOScale(endScale, 0.5f));
}
if (startPos != endPos)
{
transform.localPosition = startPos;
seq.Insert(0f, transform.DOLocalMove(endPos, 0.5f));
}
seq.AppendCallback(() => {
ac();
});
}
}