mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 15:24:55 +08:00
Add create/add/set-custom-skin.
This commit is contained in:
parent
5fed1d6a33
commit
2fa8601e05
@ -150,6 +150,43 @@
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "create-custom-skin",
|
||||
"scriptName": "CreateCustomSkin",
|
||||
"highlight": false,
|
||||
"params": [
|
||||
{
|
||||
"id": "skin-name",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "add-custom-skin",
|
||||
"scriptName": "AddCustomSkin",
|
||||
"highlight": false,
|
||||
"params": [
|
||||
{
|
||||
"id": "custom-skin-name",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"id": "skin-to-add-name",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "set-custom-skin",
|
||||
"scriptName": "SetCustomSkin",
|
||||
"highlight": false,
|
||||
"params": [
|
||||
{
|
||||
"id": "skin-name",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"expressions": [
|
||||
|
||||
@ -39,6 +39,18 @@ C3.Plugins.EsotericSoftware_SpineConstruct3.Acts =
|
||||
|
||||
SetAttachment (this: SDKInstanceClass, slotName: string, attachmentName: string) {
|
||||
this.setAttachment(slotName, attachmentName === "" ? null : attachmentName);
|
||||
},
|
||||
|
||||
CreateCustomSkin (this: SDKInstanceClass, skinName: string) {
|
||||
this.createCustomSkin(skinName);
|
||||
},
|
||||
|
||||
AddCustomSkin (this: SDKInstanceClass, customSkinName: string, skinToAddName: string) {
|
||||
this.addCustomSkin(customSkinName, skinToAddName);
|
||||
},
|
||||
|
||||
SetCustomSkin (this: SDKInstanceClass, skinName: string) {
|
||||
this.setCustomSkin(skinName);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import type { AnimationState, AnimationStateListener, AssetLoader, Event, Skeleton, SkeletonRendererCore, TextureAtlas, } from "@esotericsoftware/spine-construct3-lib";
|
||||
import type { AnimationState, AnimationStateListener, AssetLoader, Event, Skeleton, SkeletonRendererCore, Skin, TextureAtlas, } from "@esotericsoftware/spine-construct3-lib";
|
||||
|
||||
const C3 = globalThis.C3;
|
||||
const spine = globalThis.spine;
|
||||
@ -18,6 +18,7 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
|
||||
propScaleY = 1;
|
||||
propFlipX = false;
|
||||
isPlaying = true;
|
||||
customSkins: Record<string, Skin> = {};
|
||||
|
||||
textureAtlas?: TextureAtlas;
|
||||
renderer?: IRenderer;
|
||||
@ -183,6 +184,45 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
|
||||
this.skeleton?.setAttachment(slotName, attachmentName);
|
||||
}
|
||||
|
||||
public createCustomSkin (skinName: string) {
|
||||
if (!this.skeleton) return;
|
||||
|
||||
if (this.customSkins[skinName]) {
|
||||
this.customSkins[skinName].clear();
|
||||
} else {
|
||||
this.customSkins[skinName] = new spine.Skin(skinName);
|
||||
}
|
||||
}
|
||||
|
||||
public addCustomSkin (customSkinName: string, skinToAddName: string) {
|
||||
if (!this.skeleton) return;
|
||||
|
||||
if (!this.customSkins[customSkinName]) {
|
||||
console.warn(`[Spine] Custom skin "${customSkinName}" does not exist. Create it first.`);
|
||||
return;
|
||||
}
|
||||
|
||||
const skinToAdd = this.skeleton.data.findSkin(skinToAddName);
|
||||
if (!skinToAdd) {
|
||||
console.warn(`[Spine] Skin "${skinToAddName}" not found in skeleton data.`);
|
||||
return;
|
||||
}
|
||||
|
||||
this.customSkins[customSkinName].addSkin(skinToAdd);
|
||||
}
|
||||
|
||||
public setCustomSkin (skinName: string) {
|
||||
if (!this.skeleton) return;
|
||||
|
||||
if (!this.customSkins[skinName]) {
|
||||
console.warn(`[Spine] Custom skin "${skinName}" does not exist.`);
|
||||
return;
|
||||
}
|
||||
|
||||
this.skeleton.setSkin(this.customSkins[skinName]);
|
||||
this.skeleton.setupPose();
|
||||
}
|
||||
|
||||
private _setSkin () {
|
||||
const { skeleton } = this;
|
||||
if (!skeleton) return;
|
||||
|
||||
@ -224,6 +224,43 @@
|
||||
"desc": "Name of the attachment to set"
|
||||
}
|
||||
}
|
||||
},
|
||||
"create-custom-skin": {
|
||||
"list-name": "Create custom skin",
|
||||
"display-text": "Create custom skin {0}",
|
||||
"description": "Create a new custom skin that can combine multiple skins",
|
||||
"params": {
|
||||
"skin-name": {
|
||||
"name": "Skin name",
|
||||
"desc": "Name for the custom skin"
|
||||
}
|
||||
}
|
||||
},
|
||||
"add-custom-skin": {
|
||||
"list-name": "Add to custom skin",
|
||||
"display-text": "Add skin {1} to custom skin {0}",
|
||||
"description": "Add an existing skin to a custom skin",
|
||||
"params": {
|
||||
"custom-skin-name": {
|
||||
"name": "Custom skin name",
|
||||
"desc": "Name of the custom skin to add to"
|
||||
},
|
||||
"skin-to-add-name": {
|
||||
"name": "Skin to add",
|
||||
"desc": "Name of the existing skin to add"
|
||||
}
|
||||
}
|
||||
},
|
||||
"set-custom-skin": {
|
||||
"list-name": "Set custom skin",
|
||||
"display-text": "Set custom skin {0}",
|
||||
"description": "Apply a custom skin to the skeleton",
|
||||
"params": {
|
||||
"skin-name": {
|
||||
"name": "Skin name",
|
||||
"desc": "Name of the custom skin to apply"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"expressions": {
|
||||
|
||||
@ -226,6 +226,43 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"create-custom-skin": {
|
||||
"list-name": "创建自定义皮肤",
|
||||
"display-text": "创建自定义皮肤{0}",
|
||||
"description": "创建一个可以组合多个皮肤的新自定义皮肤",
|
||||
"params": {
|
||||
"skin-name": {
|
||||
"name": "皮肤名称",
|
||||
"desc": "自定义皮肤的名称"
|
||||
}
|
||||
}
|
||||
},
|
||||
"add-custom-skin": {
|
||||
"list-name": "添加到自定义皮肤",
|
||||
"display-text": "将皮肤{1}添加到自定义皮肤{0}",
|
||||
"description": "将现有皮肤添加到自定义皮肤",
|
||||
"params": {
|
||||
"custom-skin-name": {
|
||||
"name": "自定义皮肤名称",
|
||||
"desc": "要添加到的自定义皮肤名称"
|
||||
},
|
||||
"skin-to-add-name": {
|
||||
"name": "要添加的皮肤",
|
||||
"desc": "要添加的现有皮肤名称"
|
||||
}
|
||||
}
|
||||
},
|
||||
"set-custom-skin": {
|
||||
"list-name": "设置自定义皮肤",
|
||||
"display-text": "设置自定义皮肤{0}",
|
||||
"description": "将自定义皮肤应用到骨架",
|
||||
"params": {
|
||||
"skin-name": {
|
||||
"name": "皮肤名称",
|
||||
"desc": "要应用的自定义皮肤名称"
|
||||
}
|
||||
}
|
||||
},
|
||||
"expressions": {
|
||||
"double": {
|
||||
"description": "将数字翻倍。",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user