HDSL

Hello. I'm quite new on using Spine, and was wondering what's the proper way to set up events firing on animations. I'm using Unity, C#, and 2DToolkit. For some reason my scripts are not able to capture any events I put on the animations. I'm using what was given in the example:
void Start () {
skeleton = GetComponent<SkeletonAnimation>();
skeleton.state.Event += Event;
}
public void Event (object sender, EventTriggeredArgs e) {
Debug.Log(e.TrackIndex + " " + skeleton.state.GetCurrent(e.TrackIndex) + ": event " + e.Event + ", " + e.Event.Int);
}
I created a new event on my animation, and put it on one of the key frames of it. For some reason the event is never captured or fired. What could I be doing wrong?
HDSL
  • Сообщения: 4

Nate

Should work. I just committed a fix for events sometimes not firing, so you could try updating to the latest. Also note, if your event is on frame zero and the SkeletonAnimation component updates for the first time before your code adds the event listener, then your listener won't get notified for that event.
Аватара пользователя
Nate

Nate
  • Сообщения: 9766

HDSL

Thanks for the reply. My event is on frame zero, so that might be it. When exactly is it that the component gets updated? Right now I'm adding the event listener before I fire the animation with the event, though the another animation is already running by that time.

Also, I downloaded the latest runtimes and got an error:

http://i909.photobucket.com/albums/ac29 ... d32fd1.png

Tracking it down:

http://i909.photobucket.com/albums/ac29 ... 008dfa.png

Last thing, I think the examples might be outdated, but loading up the JSON skeleton from the spineboy example into the editor, and then clicking on any of the events will crash the editor.
HDSL
  • Сообщения: 4

Pharan

HDSL писал(а):Tracking it down:

http://i909.photobucket.com/albums/ac29 ... 008dfa.png
:D
Аватара пользователя
Pharan
  • Сообщения: 5366

HDSL

I feel dumb now :P So I changed "apply" to "Apply" and "Integer.MAX_VALUE" to "int.MaxValue". Everything seems to work now.

Edit: My event is also working now without changing anything, so I guess it was the runtime.
HDSL
  • Сообщения: 4

Nate

Eek, fixed, sorry!
Аватара пользователя
Nate

Nate
  • Сообщения: 9766


Вернуться в Runtimes