diff --git a/spine-ts/spine-construct3/src/aces.json b/spine-ts/spine-construct3/src/aces.json index b2be085f7..d47c42909 100644 --- a/spine-ts/spine-construct3/src/aces.json +++ b/spine-ts/spine-construct3/src/aces.json @@ -385,6 +385,18 @@ "expressionName": "CurrentSkin", "highlight": false, "returnType": "string" + }, + { + "id": "current-animation", + "expressionName": "CurrentAnimation", + "highlight": false, + "returnType": "string", + "params": [ + { + "id": "track-index", + "type": "number" + } + ] } ] } diff --git a/spine-ts/spine-construct3/src/c3runtime/expressions.ts b/spine-ts/spine-construct3/src/c3runtime/expressions.ts index e94d8dfc9..a6f70ed85 100644 --- a/spine-ts/spine-construct3/src/c3runtime/expressions.ts +++ b/spine-ts/spine-construct3/src/c3runtime/expressions.ts @@ -31,6 +31,10 @@ C3.Plugins.EsotericSoftware_SpineConstruct3.Exps = CurrentSkin (this: SDKInstanceClass) { return this.getCurrentSkin(); + }, + + CurrentAnimation (this: SDKInstanceClass, trackIndex: number) { + return this.getCurrentAnimation(trackIndex); } }; diff --git a/spine-ts/spine-construct3/src/c3runtime/instance.ts b/spine-ts/spine-construct3/src/c3runtime/instance.ts index b989f4ed3..42263e321 100644 --- a/spine-ts/spine-construct3/src/c3runtime/instance.ts +++ b/spine-ts/spine-construct3/src/c3runtime/instance.ts @@ -435,6 +435,18 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase { return skin.name; } + public getCurrentAnimation (trackIndex: number): string { + if (!this.skeleton) return ""; + + const { state } = this; + if (!state) return ""; + + const track = state.tracks[trackIndex]; + if (!track || !track.animation) return ""; + + return track.animation.name; + } + private _setSkin () { const { skeleton } = this; if (!skeleton) return; diff --git a/spine-ts/spine-construct3/src/lang/en-US.json b/spine-ts/spine-construct3/src/lang/en-US.json index 717556b42..6e9c77c07 100644 --- a/spine-ts/spine-construct3/src/lang/en-US.json +++ b/spine-ts/spine-construct3/src/lang/en-US.json @@ -460,6 +460,16 @@ "current-skin": { "description": "Get the current skin name. Returns comma-separated names if multiple skins are active.", "translated-name": "CurrentSkin" + }, + "current-animation": { + "description": "Get the name of the currently playing animation on a specific track.", + "translated-name": "CurrentAnimation", + "params": { + "track-index": { + "name": "Track index", + "desc": "Index of the track" + } + } } } } diff --git a/spine-ts/spine-construct3/src/lang/zh-CN.json b/spine-ts/spine-construct3/src/lang/zh-CN.json index 91ce54215..fd971e0c3 100644 --- a/spine-ts/spine-construct3/src/lang/zh-CN.json +++ b/spine-ts/spine-construct3/src/lang/zh-CN.json @@ -460,6 +460,16 @@ "current-skin": { "description": "获取当前皮肤名称。如果有多个皮肤处于活动状态,返回逗号分隔的名称。", "translated-name": "CurrentSkin" + }, + "current-animation": { + "description": "获取特定轨道上当前播放的动画名称。", + "translated-name": "CurrentAnimation", + "params": { + "track-index": { + "name": "轨道索引", + "desc": "轨道的索引" + } + } } } }