using Animancer; using System; using UnityEngine; public class PlayerVisual : MonoBehaviour { [SerializeField] NamedAnimancerComponent namedAnimancer; [SerializeField] private INFO _playerInfo; private void PlayActionEventHandler(PlayActionEvent @event) { BrewMonster.Logger.Log("PlayActionEventHandler : "+@event.AnimationName); namedAnimancer.TryPlay(@event.AnimationName); } public void InitHostPlayerEventDoneHandler() { namedAnimancer = GetComponentInChildren(); if(namedAnimancer == null) { BrewMonster.Logger.LogError("animancer == null"); return; } var player = GetComponentInParent(); if(player == null) { BrewMonster.Logger.LogError("player == null"); return; } _playerInfo = player.GetPlayInfo(); EventBus.SubscribeChannel(_playerInfo.cid, PlayActionEventHandler); } private void OnDestroy() { EventBus.UnsubscribeAllInChannel(_playerInfo.cid); } public bool IsAnimationExist(string animationName) { return namedAnimancer.States.TryGet("ActionName", out var existingState) ? true : false; } }