I want to try to trigger a custom animation event
But the HandleEvent event registered in start is not triggered
The following method must be used to register the trigger event later
What could be the cause of this problem? 😢
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AnimationEvent : MonoBehaviour
{
public SkeletonAnimation skeletonAnimation;
public void Start()
{
skeletonAnimation = GetComponent<SkeletonAnimation>();
skeletonAnimation.AnimationState.Event += HandleEvent;
StartCoroutine(InitEvent());
}
IEnumerator InitEvent()
{
yield return Yielders.WaitForSeconds(1);
skeletonAnimation.AnimationState.Event += HandleEvent;
}
void HandleEvent(Spine.TrackEntry trackEntry, Spine.Event e)
{
Debug.Log("Fire_Movent");
if (e.Data.Name == "Fire_Movent")
{
Debug.Log("Fire_Movent");
}
Debug.Log("Fire_Movent");
}
}