Spine events data stores track and animation when triggered.

This commit is contained in:
Davide Tantillo 2025-12-15 16:12:26 +01:00
parent ed94892283
commit f5f1f1d297
2 changed files with 11 additions and 11 deletions

View File

@ -52,8 +52,8 @@ C3.Plugins.EsotericSoftware_SpineConstruct3.Exps =
if (field === "volume") return this.triggeredEventData?.volume;
if (field === "audiopath") return this.triggeredEventData?.data.audioPath;
if (field === "event") return this.triggeredEventData?.data.name;
if (field === "animation") return this.triggeredEventAnimation;
if (field === "track") return this.triggeredEventTrack;
if (field === "animation") return this.triggeredEventData?.animation;
if (field === "track") return this.triggeredEventData?.track;
return "";
}
};

View File

@ -36,7 +36,7 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
public triggeredEventTrack = -1;
public triggeredEventAnimation = "";
public triggeredEventName = "";
public triggeredEventData?: Event;
public triggeredEventData?: Event & { track: number, animation: string };
private assetLoader: AssetLoader;
private skeletonRenderer?: C3RendererRuntime;
@ -547,21 +547,21 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
}
}
private triggetAnimationEvent (eventName: string, track: number, animation: string, event?: Event) {
private triggerAnimationEvent (eventName: string, track: number, animation: string, event?: Event) {
this.triggeredEventTrack = track;
this.triggeredEventAnimation = animation;
this.triggeredEventName = eventName;
this.triggeredEventData = event;
if (event) this.triggeredEventData = { ...event, track, animation };
this._trigger(C3.Plugins.EsotericSoftware_SpineConstruct3.Cnds.OnAnimationEvent);
}
private makeTrackListener = (track: number, animation: string): AnimationStateListener => ({
start: () => this.triggetAnimationEvent("start", track, animation),
dispose: () => this.triggetAnimationEvent("dispose", track, animation),
event: (_, event) => this.triggetAnimationEvent("event", track, animation, event),
interrupt: () => this.triggetAnimationEvent("interrupt", track, animation),
end: () => this.triggetAnimationEvent("end", track, animation),
complete: () => this.triggetAnimationEvent("complete", track, animation),
start: () => this.triggerAnimationEvent("start", track, animation),
dispose: () => this.triggerAnimationEvent("dispose", track, animation),
event: (_, event) => this.triggerAnimationEvent("event", track, animation, event),
interrupt: () => this.triggerAnimationEvent("interrupt", track, animation),
end: () => this.triggerAnimationEvent("end", track, animation),
complete: () => this.triggerAnimationEvent("complete", track, animation),
})
/**********/