diff --git a/spine-ts/spine-construct3/src/aces.json b/spine-ts/spine-construct3/src/aces.json index d3621acfb..4b73339ba 100644 --- a/spine-ts/spine-construct3/src/aces.json +++ b/spine-ts/spine-construct3/src/aces.json @@ -249,6 +249,32 @@ "items": ["none", "reset", "update", "pose"] } ] + }, + { + "id": "set-slot-color", + "scriptName": "SetSlotColor", + "highlight": false, + "params": [ + { + "id": "slot-name", + "type": "string" + }, + { + "id": "color", + "type": "string" + } + ] + }, + { + "id": "reset-slot-colors", + "scriptName": "ResetSlotColors", + "highlight": false, + "params": [ + { + "id": "slot-name", + "type": "string" + } + ] } ], "expressions": [ diff --git a/spine-ts/spine-construct3/src/c3runtime/actions.ts b/spine-ts/spine-construct3/src/c3runtime/actions.ts index 50bfcb9fa..27123e0f2 100644 --- a/spine-ts/spine-construct3/src/c3runtime/actions.ts +++ b/spine-ts/spine-construct3/src/c3runtime/actions.ts @@ -67,6 +67,14 @@ C3.Plugins.EsotericSoftware_SpineConstruct3.Acts = SetPhysicsMode (this: SDKInstanceClass, mode: 0 | 1 | 2 | 3) { this.setPhysicsMode(mode); + }, + + SetSlotColor (this: SDKInstanceClass, slotName: string, color: string) { + this.setSlotColor(slotName, color); + }, + + ResetSlotColors (this: SDKInstanceClass, slotName: string) { + this.resetSlotColors(slotName); } }; diff --git a/spine-ts/spine-construct3/src/c3runtime/instance.ts b/spine-ts/spine-construct3/src/c3runtime/instance.ts index 3ce961175..ab3ad930f 100644 --- a/spine-ts/spine-construct3/src/c3runtime/instance.ts +++ b/spine-ts/spine-construct3/src/c3runtime/instance.ts @@ -271,6 +271,42 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase { } } + public setSlotColor (slotName: string, color: string) { + const { skeleton } = this; + if (!skeleton) { + console.warn('[Spine] setSlotColor: no skeleton'); + return; + } + + const slot = skeleton.findSlot(slotName); + if (!slot) { + console.warn(`[Spine] setSlotColor: slot not found: ${slotName}`); + return; + } + + slot.pose.color.setFromString(color); + } + + public resetSlotColors (slotName: string = "") { + const { skeleton } = this; + if (!skeleton) { + console.warn('[Spine] resetSlotColors: no skeleton'); + return; + } + + if (slotName === "") { + for (const slot of skeleton.slots) + slot.pose.color.setFromColor(slot.data.setup.color); + } else { + const slot = skeleton.findSlot(slotName); + if (!slot) { + console.warn(`[Spine] resetSlotColors: slot not found: ${slotName}`); + return; + } + slot.pose.color.setFromColor(slot.data.setup.color); + } + } + 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 38db8c0f7..edebbdf14 100644 --- a/spine-ts/spine-construct3/src/lang/en-US.json +++ b/spine-ts/spine-construct3/src/lang/en-US.json @@ -331,6 +331,32 @@ } } } + }, + "set-slot-color": { + "list-name": "Set slot color", + "display-text": "Set slot {0} color to {1}", + "description": "Set the color of a slot. Accepts hex colors (#RRGGBB or #RRGGBBAA) or color names.", + "params": { + "slot-name": { + "name": "Slot name", + "desc": "Name of the slot to modify" + }, + "color": { + "name": "Color", + "desc": "Color value (hex like #FF0000 or color name)" + } + } + }, + "reset-slot-colors": { + "list-name": "Reset slot colors", + "display-text": "Reset slot colors for {0}", + "description": "Reset slot colors to their setup pose values. Leave slot name empty to reset all slots.", + "params": { + "slot-name": { + "name": "Slot name", + "desc": "Name of the slot to reset. Leave empty to reset all slots." + } + } } }, "expressions": { diff --git a/spine-ts/spine-construct3/src/lang/zh-CN.json b/spine-ts/spine-construct3/src/lang/zh-CN.json index 5134cbbc4..395f28624 100644 --- a/spine-ts/spine-construct3/src/lang/zh-CN.json +++ b/spine-ts/spine-construct3/src/lang/zh-CN.json @@ -333,6 +333,32 @@ } } }, + "set-slot-color": { + "list-name": "设置插槽颜色", + "display-text": "设置插槽{0}的颜色为{1}", + "description": "设置插槽的颜色。接受十六进制颜色(#RRGGBB 或 #RRGGBBAA)或颜色名称。", + "params": { + "slot-name": { + "name": "插槽名称", + "desc": "要修改的插槽名称" + }, + "color": { + "name": "颜色", + "desc": "颜色值(十六进制如 #FF0000 或颜色名称)" + } + } + }, + "reset-slot-colors": { + "list-name": "重置插槽颜色", + "display-text": "重置插槽{0}的颜色", + "description": "将插槽颜色重置为设置姿势值。留空插槽名称以重置所有插槽。", + "params": { + "slot-name": { + "name": "插槽名称", + "desc": "要重置的插槽名称。留空以重置所有插槽。" + } + } + }, "expressions": { "double": { "description": "将数字翻倍。",