Files
test/Assets/Scripts/PlayerVisual.cs
T
2025-09-19 17:39:39 +07:00

34 lines
1019 B
C#

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);
}
}