Skip to content

Commit f108d4e

Browse files
authored
Expose both the skin property and the setSkin method interface for the Spine skeleton across native and web implementations. (#18715)
1 parent e20e7cd commit f108d4e

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

native/cocos/bindings/manual/jsb_spine_manual.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,30 @@ static bool js_spine_Slot_getAttachment(se::State& s) {
582582
}
583583
SE_BIND_FUNC(js_spine_Slot_getAttachment)
584584

585+
static bool js_spine_Skeleton_setSkin(se::State& s)
586+
{
587+
CC_UNUSED bool ok = true;
588+
const auto& args = s.args();
589+
size_t argc = args.size();
590+
spine::Skeleton *arg1 = (spine::Skeleton *) NULL ;
591+
spine::Skin *arg2 = (spine::Skin *) NULL ;
592+
593+
if(argc != 1) {
594+
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
595+
return false;
596+
}
597+
arg1 = SE_THIS_OBJECT<spine::Skeleton>(s);
598+
if (nullptr == arg1) return true;
599+
600+
ok &= sevalue_to_native(args[0], &arg2, s.thisObject());
601+
SE_PRECONDITION2(ok, false, "Error processing arguments");
602+
(arg1)->setSkin(arg2);
603+
604+
605+
return true;
606+
}
607+
SE_BIND_FUNC(js_spine_Skeleton_setSkin)
608+
585609
bool register_all_spine_manual(se::Object *obj) {
586610
// Get the ns
587611
se::Value nsVal;
@@ -600,6 +624,7 @@ bool register_all_spine_manual(se::Object *obj) {
600624
__jsb_spine_VertexAttachment_proto->defineFunction("computeWorldVertices", _SE(js_VertexAttachment_computeWorldVertices));
601625
__jsb_spine_RegionAttachment_proto->defineFunction("computeWorldVertices", _SE(js_RegionAttachment_computeWorldVertices));
602626
__jsb_spine_Skeleton_proto->defineFunction("getBounds", _SE(js_Skeleton_getBounds));
627+
__jsb_spine_Skeleton_proto->defineFunction("setSkin", _SE(js_spine_Skeleton_setSkin));
603628
__jsb_spine_Skin_proto->defineFunction("getAttachmentsForSlot", _SE(js_Skin_findAttachmentsForSlot));
604629
__jsb_spine_Bone_proto->defineFunction("worldToLocal", _SE(js_Bone_worldToLocal));
605630
__jsb_spine_Bone_proto->defineFunction("localToWorld", _SE(js_Bone_localToWorld));

native/cocos/editor-support/spine-wasm/3.8/spine-type-export.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1262,7 +1262,7 @@ EMSCRIPTEN_BINDINGS(spine) {
12621262
return &obj.getPathConstraints(); }), allow_raw_pointer<SPVectorPathConstraintPtr>())
12631263
.function("getUpdateCacheList", optional_override([](Skeleton &obj){
12641264
return &obj.getUpdateCacheList(); }), allow_raw_pointer<SPVectorUpdatablePtr>())
1265-
.property("skin", &Skeleton::getSkin)
1265+
.property("skin", &Skeleton::_skin)
12661266
.property("color", GETTER_RVAL_TO_PTR(Skeleton, getColor, Color*))
12671267
.property("time", &Skeleton::_time)
12681268
.property("scaleX", &Skeleton::_scaleX)

native/cocos/editor-support/spine-wasm/4.2/spine-type-export.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1297,7 +1297,7 @@ EMSCRIPTEN_BINDINGS(spine) {
12971297
return &obj.getPathConstraints(); }), allow_raw_pointer<SPVectorPathConstraintPtr>())
12981298
.function("getUpdateCacheList", optional_override([](Skeleton &obj){
12991299
return &obj.getUpdateCacheList(); }), allow_raw_pointer<SPVectorUpdatablePtr>())
1300-
.property("skin", &Skeleton::getSkin)
1300+
.property("skin", &Skeleton::_skin)
13011301
.property("color", GETTER_RVAL_TO_PTR(Skeleton, getColor, Color*))
13021302
.property("time", &Skeleton::_time)
13031303
.property("scaleX", &Skeleton::_scaleX)

native/external-config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
"type": "github",
44
"owner": "cocos",
55
"name": "cocos-engine-external",
6-
"checkout": "v3.8.7-13"
6+
"checkout": "v3.8.7-14"
77
}
88
}

0 commit comments

Comments
 (0)