- Assets/_Game/ 하위로 게임 에셋 통합 - External/ 패키지 벤더별 분류 (Synty, Animations, UI) - 에셋 네이밍 컨벤션 확립 및 적용 (Data_Skill_, Data_SkillEffect_, Prefab_, Anim_, Model_, BT_ 등) - pre-commit hook으로 네이밍 컨벤션 자동 검사 추가 - RESTRUCTURE_CHECKLIST.md 작성 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
64 lines
1.6 KiB
C#
64 lines
1.6 KiB
C#
using System;
|
|
using Unity.Behavior;
|
|
using UnityEngine;
|
|
using Action = Unity.Behavior.Action;
|
|
using Unity.Properties;
|
|
|
|
[Serializable, GeneratePropertyBag]
|
|
[NodeDescription(name: "PlayAnimation", story: "[애니메이션] 재생", category: "Action", id: "b558ee0df6e00cd2e6bb2273b4f59cd2")]
|
|
public partial class PlayAnimationAction : Action
|
|
{
|
|
[SerializeReference]
|
|
public BlackboardVariable<string> AnimationName = new BlackboardVariable<string>("");
|
|
|
|
[SerializeReference]
|
|
public BlackboardVariable<bool> WaitForCompletion = new BlackboardVariable<bool>(true);
|
|
|
|
private Animator animator;
|
|
private bool animationStarted;
|
|
|
|
protected override Status OnStart()
|
|
{
|
|
animator = GameObject.GetComponentInChildren<Animator>();
|
|
|
|
if (animator == null || string.IsNullOrEmpty(AnimationName.Value))
|
|
{
|
|
return Status.Failure;
|
|
}
|
|
|
|
animator.Play(AnimationName.Value);
|
|
animationStarted = true;
|
|
|
|
if (!WaitForCompletion.Value)
|
|
{
|
|
return Status.Success;
|
|
}
|
|
|
|
return Status.Running;
|
|
}
|
|
|
|
protected override Status OnUpdate()
|
|
{
|
|
if (!WaitForCompletion.Value)
|
|
{
|
|
return Status.Success;
|
|
}
|
|
|
|
if (animator == null)
|
|
{
|
|
return Status.Failure;
|
|
}
|
|
|
|
var stateInfo = animator.GetCurrentAnimatorStateInfo(0);
|
|
|
|
// 애니메이션이 완료되었는지 확인
|
|
if (stateInfo.IsName(AnimationName.Value) && stateInfo.normalizedTime >= 1f)
|
|
{
|
|
return Status.Success;
|
|
}
|
|
|
|
return Status.Running;
|
|
}
|
|
}
|
|
|