Skip to content

Commit 7087c23

Browse files
authored
Revert "refine Skeleton's defaultSkin, defaultAnimation (#16635)" (#16972)
This reverts commit 69319a7.
1 parent 15bffa2 commit 7087c23

2 files changed

Lines changed: 15 additions & 26 deletions

File tree

cocos/spine/skeleton.ts

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
THE SOFTWARE.
2323
*/
2424
import { EDITOR_NOT_IN_PREVIEW, JSB } from 'internal:constants';
25-
// eslint-disable-next-line max-len
26-
import { ccclass, executeInEditMode, help, menu, serializable, formerlySerializedAs, type, displayName, override, displayOrder, editable, tooltip } from 'cc.decorator';
25+
import { ccclass, executeInEditMode, help, menu, serializable, type, displayName, override, displayOrder, editable, tooltip } from 'cc.decorator';
2726
import { Material, Texture2D } from '../asset/assets';
2827
import { error, logID, warn } from '../core/platform/debug';
2928
import { Enum, EnumType, ccenum } from '../core/value-types/enum';
@@ -205,11 +204,9 @@ export class Skeleton extends UIRenderer {
205204
@serializable
206205
protected _skeletonData: SkeletonData | null = null;
207206
@serializable
208-
@formerlySerializedAs('defaultSkin')
209-
protected _defaultSkin = '';
207+
protected defaultSkin = '';
210208
@serializable
211-
@formerlySerializedAs('defaultAnimation')
212-
protected _defaultAnimation = '';
209+
protected defaultAnimation = '';
213210
/**
214211
* @en Indicates whether to enable premultiplied alpha.
215212
* You should disable this option when image's transparent area appears to have opaque pixels,
@@ -337,14 +334,6 @@ export class Skeleton extends UIRenderer {
337334
*/
338335
get drawList (): RecyclePool<SkeletonDrawData> { return this._drawList; }
339336

340-
get defaultSkin (): string {
341-
return this._defaultSkin;
342-
}
343-
344-
get defaultAnimation (): string {
345-
return this._defaultAnimation;
346-
}
347-
348337
/**
349338
* @en
350339
* The skeleton data contains the skeleton information (bind pose bones, slots, draw order,
@@ -367,8 +356,8 @@ export class Skeleton extends UIRenderer {
367356
if (this._skeletonData !== value) {
368357
this.destroyRenderData();
369358
this._skeletonData = value as any;
370-
this._defaultSkin = '';
371-
this._defaultAnimation = '';
359+
this.defaultSkin = '';
360+
this.defaultAnimation = '';
372361
this._animationName = '';
373362
this._skinName = '';
374363
this._updateSkeletonData();
@@ -386,14 +375,14 @@ export class Skeleton extends UIRenderer {
386375
if (this.skeletonData) {
387376
const skinsEnum = this.skeletonData.getSkinsEnum();
388377
if (skinsEnum) {
389-
if (this._defaultSkin === '') {
378+
if (this.defaultSkin === '') {
390379
// eslint-disable-next-line no-prototype-builtins
391380
if (skinsEnum.hasOwnProperty(0)) {
392381
this._defaultSkinIndex = 0;
393382
return 0;
394383
}
395384
} else {
396-
const skinIndex = skinsEnum[this._defaultSkin];
385+
const skinIndex = skinsEnum[this.defaultSkin];
397386
if (skinIndex !== undefined) {
398387
return skinIndex;
399388
}
@@ -417,8 +406,8 @@ export class Skeleton extends UIRenderer {
417406

418407
const skinName = skinsEnum[value];
419408
if (skinName !== undefined) {
420-
this._defaultSkin = String(skinName);
421-
this.setSkin(this._defaultSkin);
409+
this.defaultSkin = String(skinName);
410+
this.setSkin(this.defaultSkin);
422411
this._refreshInspector();
423412
this.markForUpdateRenderData();
424413
} else {
@@ -434,7 +423,7 @@ export class Skeleton extends UIRenderer {
434423
@type(DefaultAnimsEnum)
435424
@tooltip('i18n:COMPONENT.skeleton.animation')
436425
get _animationIndex (): number {
437-
const animationName = EDITOR_NOT_IN_PREVIEW ? this._defaultAnimation : this.animation;
426+
const animationName = EDITOR_NOT_IN_PREVIEW ? this.defaultAnimation : this.animation;
438427
if (this.skeletonData) {
439428
if (animationName) {
440429
const animsEnum = this.skeletonData.getAnimsEnum();
@@ -466,7 +455,7 @@ export class Skeleton extends UIRenderer {
466455
if (animName !== undefined) {
467456
this.animation = animName;
468457
if (EDITOR_NOT_IN_PREVIEW) {
469-
this._defaultAnimation = animName;
458+
this.defaultAnimation = animName;
470459
this._refreshInspector();
471460
} else {
472461
this.animation = animName;
@@ -776,8 +765,8 @@ export class Skeleton extends UIRenderer {
776765
this._textures = skeletonData.textures;
777766

778767
this._refreshInspector();
779-
if (this._defaultAnimation) this.animation = this._defaultAnimation.toString();
780-
if (this._defaultSkin && this._defaultSkin !== '') this.setSkin(this._defaultSkin);
768+
if (this.defaultAnimation) this.animation = this.defaultAnimation.toString();
769+
if (this.defaultSkin && this.defaultSkin !== '') this.setSkin(this.defaultSkin);
781770
this._updateUseTint();
782771
this._indexBoneSockets();
783772
this._updateSocketBindings();

platforms/native/engine/jsb-spine-skeleton.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -694,8 +694,8 @@ const cacheManager = require('./jsb-cache-manager');
694694
this.attachUtil.init(this);
695695
this._preCacheMode = this._cacheMode;
696696

697-
this._defaultSkin && this._nativeSkeleton.setSkin(this._defaultSkin);
698-
this.animation = this._defaultAnimation;
697+
this.defaultSkin && this._nativeSkeleton.setSkin(this.defaultSkin);
698+
this.animation = this.defaultAnimation;
699699
} else if (this._nativeSkeleton) {
700700
this._nativeSkeleton.stopSchedule();
701701
this._nativeSkeleton._comp = null;

0 commit comments

Comments
 (0)