mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-09 16:48:43 +08:00
Add set-slot-color and reset-slot-colors.
This commit is contained in:
parent
2918788364
commit
34e56af5c5
@ -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": [
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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": {
|
||||
|
||||
@ -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": "将数字翻倍。",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user