animation host done

This commit is contained in:
VDH
2025-09-19 17:39:39 +07:00
parent 53013d7887
commit 0dd73da3c4
12 changed files with 195 additions and 52 deletions
+33
View File
@@ -0,0 +1,33 @@
using Animancer;
using System;
using UnityEngine;
public class PlayerVisual : MonoBehaviour
{
[SerializeField] NamedAnimancerComponent animancer;
private void Awake()
{
EventBus.Subscribe<InitHostPlayerEventDone>(InitHostPlayerEventDoneHandler);
EventBus.Subscribe<PlayActionEvent>(PlayActionEventHandler);
}
private void PlayActionEventHandler(PlayActionEvent @event)
{
BrewMonster.Logger.Log("PlayActionEventHandler : "+@event.AnimationName);
animancer.TryPlay(@event.AnimationName);
}
private void InitHostPlayerEventDoneHandler(InitHostPlayerEventDone done)
{
animancer = GetComponentInChildren<NamedAnimancerComponent>();
if(animancer == null)
{
BrewMonster.Logger.Log("animancer == null");
}
}
private void OnDestroy()
{
EventBus.Unsubscribe<InitHostPlayerEventDone>(InitHostPlayerEventDoneHandler);
EventBus.Unsubscribe<PlayActionEvent>(PlayActionEventHandler);
}
}