From 0a9774f6e96c13bdc4a0add52b30bb3382c18823 Mon Sep 17 00:00:00 2001 From: SmallMain Date: Tue, 5 Jul 2022 11:06:14 +0800 Subject: [PATCH] =?UTF-8?q?[jsb-adapter]=20Spine=20=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E6=89=80=E6=9C=89=E7=89=B9=E6=80=A7=E5=8E=9F=E7=94=9F=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jsb-adapter/engine/jsb-spine-skeleton.js | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/jsb-adapter/engine/jsb-spine-skeleton.js b/jsb-adapter/engine/jsb-spine-skeleton.js index 22bce6c3..23648b1e 100644 --- a/jsb-adapter/engine/jsb-spine-skeleton.js +++ b/jsb-adapter/engine/jsb-spine-skeleton.js @@ -66,6 +66,7 @@ const cacheManager = require('./jsb-cache-manager'); let skeletonCacheMgr = spine.SkeletonCacheMgr.getInstance(); spine.skeletonCacheMgr = skeletonCacheMgr; skeletonDataProto.destroy = function () { + this._destroyFromDynamicAtlas(); this.reset(); skeletonCacheMgr.removeSkeletonCache(this._uuid); cc.Asset.prototype.destroy.call(this); @@ -325,6 +326,15 @@ const cacheManager = require('./jsb-cache-manager'); } }; + skeleton.setVertsDirty = function () { + if (this.skeletonData) { + this._dataDirty = true; + this.constructor.__assembler__.prototype.handleDynamicAtlasAndSwitchMaterial(this); + } + this.invalidAnimationCache(); + cc.RenderComponent.prototype.setVertsDirty.call(this); + }; + skeleton.setSkeletonData = function (skeletonData) { if (null != skeletonData.width && null != skeletonData.height && 0 !== skeletonData.width && 0 !== skeletonData.height) { this.node.setContentSize(skeletonData.width, skeletonData.height); @@ -349,6 +359,9 @@ const cacheManager = require('./jsb-cache-manager'); this._nativeSkeleton = null; } + this._dataDirty = true; + this.constructor.__assembler__.prototype.handleDynamicAtlasAndSwitchMaterial(this); + let nativeSkeleton = null; if (this.isAnimationCached()) { nativeSkeleton = new spine.SkeletonCacheAnimation(uuid, this._cacheMode == AnimationCacheMode.SHARED_CACHE); @@ -769,6 +782,27 @@ const cacheManager = require('./jsb-cache-manager'); this._materialCache = null; }; + let regionAttachment = sp.spine.RegionAttachment.prototype; + + regionAttachment.getTexture2D = function (skeletonData) { + if (!this._texture2D) { + this._texture2D = skeletonData.getTextureByIndex(this.textureForJSB.getRealTextureIndex()); + } + return this._texture2D; + }; + + let meshAttachment = sp.spine.MeshAttachment.prototype; + + meshAttachment.getTexture2D = function (skeletonData) { + if (!this._texture2D) { + this._texture2D = skeletonData.getTextureByIndex(this.textureForJSB.getRealTextureIndex()); + } + return this._texture2D; + }; + + renderer.CustomAssembler.prototype.updateRenderDataForSwitchMaterial = function () { + // placeholder + }; //////////////////////////////////////////////////////////// // adapt attach util