feat(huoshan): 添加销售视图进场动画控制器
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7a2b3c4d5e6f7890abcdef1234567890
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user