SetTimeScale action and TimeScale expressions allow to specify a track.

This commit is contained in:
Davide Tantillo 2026-03-24 16:49:27 +01:00
parent a4b93c6d68
commit 02ec69de27
6 changed files with 57 additions and 17 deletions

View File

@ -294,6 +294,11 @@
"scriptName": "SetTimeScale", "scriptName": "SetTimeScale",
"highlight": false, "highlight": false,
"params": [ "params": [
{
"id": "track-index",
"type": "number",
"initial-value": -1
},
{ {
"id": "time-scale", "id": "time-scale",
"type": "number" "type": "number"
@ -833,7 +838,14 @@
"id": "time-scale", "id": "time-scale",
"expressionName": "TimeScale", "expressionName": "TimeScale",
"highlight": false, "highlight": false,
"returnType": "number" "returnType": "number",
"params": [
{
"id": "track-index",
"type": "number",
"initial-value": -1
}
]
}, },
{ {
"id": "current-animation-start", "id": "current-animation-start",

View File

@ -85,8 +85,8 @@ C3.Plugins.EsotericSoftware_SpineConstruct3.Acts =
this.setCustomSkin(skinName); this.setCustomSkin(skinName);
}, },
SetTimeScale (this: SDKInstanceClass, timeScale: number) { SetTimeScale (this: SDKInstanceClass, track: number, timeScale: number) {
this.setAnimationSpeed(timeScale); this.setTimeScale(track, timeScale);
}, },
SetAnimationTime (this: SDKInstanceClass, track: number, time: number, units: 0 | 1) { SetAnimationTime (this: SDKInstanceClass, track: number, time: number, units: 0 | 1) {

View File

@ -112,8 +112,11 @@ C3.Plugins.EsotericSoftware_SpineConstruct3.Exps =
return ""; return "";
}, },
TimeScale (this: SpineC3Instance) { TimeScale (this: SpineC3Instance, track: number) {
return this.state?.timeScale ?? 1; if (!this.state) return 1;
if (track < 0) return this.state.timeScale;
const entry = this.state.getCurrent(track);
return entry?.timeScale ?? 1;
}, },
CurrentAnimationStart (this: SpineC3Instance, trackIndex: number) { CurrentAnimationStart (this: SpineC3Instance, trackIndex: number) {

View File

@ -594,9 +594,14 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
return track.animation.name; return track.animation.name;
} }
public setAnimationSpeed (speed: number) { public setTimeScale (track: number, timeScale: number) {
if (!this.state) return; if (!this.state) return;
this.state.timeScale = speed; if (track < 0) {
this.state.timeScale = timeScale;
} else {
const entry = this.state.getCurrent(track);
if (entry) entry.timeScale = timeScale;
}
} }
public setAnimationTime (units: 0 | 1, time: number, track: number) { public setAnimationTime (units: 0 | 1, time: number, track: number) {

View File

@ -370,12 +370,16 @@
}, },
"set-time-scale": { "set-time-scale": {
"list-name": "Set time scale", "list-name": "Set time scale",
"display-text": "Set time scale to {0}", "display-text": "Set track {0} time scale to {1}",
"description": "Set the time scale of animations (1.0 = normal, 2.0 = double speed, 0.5 = half speed)", "description": "Set the time scale for a specific track or the entire animation state. When targeting a track, the time scale affects only the current animation on that track. Use -1 for the track to set the global animation state time scale. Set to 0 to pause.",
"params": { "params": {
"track-index": {
"name": "Track",
"desc": "Track index to set the time scale for, or -1 to set the global animation state time scale."
},
"time-scale": { "time-scale": {
"name": "Time scale", "name": "Time scale",
"desc": "Time scale multiplier (1.0 is normal speed)" "desc": "Time scale multiplier (1.0 is normal speed, 0 to pause)"
} }
} }
}, },
@ -906,8 +910,14 @@
} }
}, },
"time-scale": { "time-scale": {
"description": "Get the current animation time scale (speed multiplier).", "description": "Get the time scale for a specific track or the global animation state. Use -1 for the global animation state time scale.",
"translated-name": "TimeScale" "translated-name": "TimeScale",
"params": {
"track-index": {
"name": "Track",
"desc": "Track index, or -1 for the global animation state time scale."
}
}
}, },
"current-animation-start": { "current-animation-start": {
"description": "Get the start time of the current animation on the specified track.", "description": "Get the start time of the current animation on the specified track.",

View File

@ -370,12 +370,16 @@
}, },
"set-time-scale": { "set-time-scale": {
"list-name": "设置时间缩放", "list-name": "设置时间缩放",
"display-text": "将时间缩放设置为{0}", "display-text": "将轨道{0}的时间缩放设置为{1}",
"description": "设置动画时间缩放1.0 = 正常2.0 = 两倍速0.5 = 半速)", "description": "设置特定轨道或整个动画状态的时间缩放。针对轨道时,时间缩放仅影响该轨道上的当前动画。使用-1设置全局动画状态时间缩放。设置为0可暂停。",
"params": { "params": {
"track-index": {
"name": "轨道",
"desc": "要设置时间缩放的轨道索引,或-1设置全局动画状态时间缩放。"
},
"time-scale": { "time-scale": {
"name": "时间缩放", "name": "时间缩放",
"desc": "时间缩放倍数1.0为正常速度)" "desc": "时间缩放倍数1.0为正常速度0为暂停"
} }
} }
}, },
@ -906,8 +910,14 @@
} }
}, },
"time-scale": { "time-scale": {
"description": "获取当前动画时间缩放(速度倍数)。", "description": "获取特定轨道或全局动画状态的时间缩放。使用-1获取全局动画状态时间缩放。",
"translated-name": "TimeScale" "translated-name": "TimeScale",
"params": {
"track-index": {
"name": "轨道",
"desc": "轨道索引,或-1获取全局动画状态时间缩放。"
}
}
}, },
"current-animation-start": { "current-animation-start": {
"description": "获取指定轨道上当前动画的开始时间。", "description": "获取指定轨道上当前动画的开始时间。",