61 lines
1.8 KiB
C#
61 lines
1.8 KiB
C#
using UnityEngine;
|
|
|
|
namespace AibisDream.MiniGame.HuoShan
|
|
{
|
|
/// <summary>
|
|
/// SaleView 进入动画控制器
|
|
/// 负责在进入销售系统时播放进入动画,包括:
|
|
/// 1. 轨道底座组伸张
|
|
/// 2. 内环和外边框放大
|
|
/// 3. 滑片从缩着变为伸出(帧动画 c→b→a)
|
|
/// 4. 夹片淡入
|
|
/// 默认保持初始(缩起)状态,进入时播放。
|
|
/// </summary>
|
|
[RequireComponent(typeof(Animator))]
|
|
public class SaleViewEnterAnimation : MonoBehaviour
|
|
{
|
|
private const string AnimParamTriggerEnter = "Enter";
|
|
|
|
[Header("Animator 配置")]
|
|
[Tooltip("Animator Controller(带 Idle/Enter 两个状态)")]
|
|
[SerializeField] private RuntimeAnimatorController animatorController;
|
|
|
|
private Animator _animator;
|
|
private int _triggerEnterId;
|
|
|
|
private void Awake()
|
|
{
|
|
_animator = GetComponent<Animator>();
|
|
if (animatorController != null)
|
|
_animator.runtimeAnimatorController = animatorController;
|
|
_triggerEnterId = Animator.StringToHash(AnimParamTriggerEnter);
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
// 确保初始状态为 Idle(缩起)
|
|
_animator.Rebind();
|
|
_animator.Update(0f);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 播放进入动画(进入销售系统时调用)
|
|
/// </summary>
|
|
public void PlayEnterAnimation()
|
|
{
|
|
if (_animator == null || !_animator.enabled) return;
|
|
_animator.SetTrigger(_triggerEnterId);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 重置到初始状态(可用于关闭时重置)
|
|
/// </summary>
|
|
public void ResetToIdle()
|
|
{
|
|
if (_animator == null) return;
|
|
_animator.Rebind();
|
|
_animator.Update(0f);
|
|
}
|
|
}
|
|
}
|