- Изменено
Spine events won't trigger spontaneously
Hey guys,
sometimes my spine events won't trigger for none of my animations.
After about 10 minutes of gameplay, without a clear reason or error,
my HandleEvents functions won't be called anymore.
Normaly it triggers as it should but sometimes it's like the event listener is gone.
My code looks like this:
void Start()
{
state.Event += HandleEvents;
}
void HandleEvents(Spine.TrackEntry entry, Spine.Event e)
{
if (e.Data.Name == eventA)
{
//Do some A stuff
}
if (e.Data.Name == eventB)
{
//Do some B stuff
}
}
I tried to debug the AnimationState Script with Visual Studio. But I'm not sure what the error is.
The picture is from debugging, while a animation is running which don't trigger.
I'm not sure if the event count is supposed to be at 0 nor if there should be a null event in there.
Does anyone know at which line in AnimationState the events should trigger so I can look after it myself?
I thought the trigger happens in the Drain() function (Line 999) and I saw that drainDisabled is true.
But I'm not sure if this is related to the problem.
Has anyone a clue what could cause this problem?
It's pretty annoying and destroys the whole game, since the character is stuck every few minutes until I restart the game.
Thank you very much
Okay I think I figured it out.
Another rare error in an event breaks the callstack so drainDisabled will never be false again.
Maybe try catch block or something similar around OnEvent would be great
Glad you figured it out.
I assume the exception was raised in your callback method, right? Was you exception silently caught somewhere else, without any error message appearing in the console?
In general we would rather not have try/catch blocks around every single event user callback, since this can be done quite easily in the callback. Then the user has total control over whether she wants the overhead or not.
Hey Harald thanks for the answer.
Yep it was silently caught and had very specfic triggers so it was a real pain to figure it out.
But hey at it least works now
This is strange, I don't see any silent catches in any Spine code, nor can I reproduce it - I always receive the error log message in the console window.