Add expression current-animation.

This commit is contained in:
Davide Tantillo 2025-11-07 10:57:14 +01:00
parent 6af077c0a6
commit ff2ee5397b
5 changed files with 48 additions and 0 deletions

View File

@ -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"
}
]
}
]
}

View File

@ -31,6 +31,10 @@ C3.Plugins.EsotericSoftware_SpineConstruct3.Exps =
CurrentSkin (this: SDKInstanceClass) {
return this.getCurrentSkin();
},
CurrentAnimation (this: SDKInstanceClass, trackIndex: number) {
return this.getCurrentAnimation(trackIndex);
}
};

View File

@ -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;

View File

@ -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"
}
}
}
}
}

View File

@ -460,6 +460,16 @@
"current-skin": {
"description": "获取当前皮肤名称。如果有多个皮肤处于活动状态,返回逗号分隔的名称。",
"translated-name": "CurrentSkin"
},
"current-animation": {
"description": "获取特定轨道上当前播放的动画名称。",
"translated-name": "CurrentAnimation",
"params": {
"track-index": {
"name": "轨道索引",
"desc": "轨道的索引"
}
}
}
}
}