42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
using System;
|
|
using System.Collections;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace UI
|
|
{
|
|
public class UIPanelExpansionAnimation : MonoBehaviour
|
|
{
|
|
[SerializeField] private Animation animationComponent;
|
|
[SerializeField] private AnimationClip clip;
|
|
|
|
public bool status = false;
|
|
public void OnStart()
|
|
{
|
|
if (status)
|
|
gameObject.SetActive(false);
|
|
}
|
|
public void OnEnded() => status = true;
|
|
public void PlayClose() => PlayBackward();
|
|
private void PlayForward()
|
|
{
|
|
animationComponent[clip.name].speed = 1f;
|
|
animationComponent.Play(clip.name);
|
|
}
|
|
private void PlayBackward()
|
|
{
|
|
animationComponent[clip.name].speed = -1f;
|
|
animationComponent[clip.name].time = animationComponent[clip.name].length;
|
|
animationComponent.Play(clip.name);
|
|
}
|
|
private void OnDisable()
|
|
{
|
|
status = false;
|
|
}
|
|
private void OnEnable()
|
|
{
|
|
PlayForward();
|
|
}
|
|
}
|
|
} |