NG_/Assets/Scripts/UI/动画/AnimationUI.cs
2024-12-13 19:40:05 +08:00

32 lines
706 B
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AnimationUI : MonoBehaviour
{
public AnimationCurve curve=new AnimationCurve(new Keyframe(0,0),new Keyframe(1,1));
private float anamationTime = 2f;
private GameObject panel;
IEnumerator ShowPanel()
{
float time = 0f;
while (time <= anamationTime)
{
panel.transform.localScale = Vector3.one * curve.Evaluate(time );
time += Time.deltaTime*anamationTime;
yield return null;
}
}
private void OnEnable()
{
panel = gameObject;
StartCoroutine(ShowPanel());
}
}