cocos / cocos-engine

Cocos simplifies game creation and distribution with Cocos Creator, a free, open-source, cross-platform game engine. Empowering millions of developers to create high-performance, engaging 2D/3D games and instant web entertainment.
https://www.cocos.com/en/creator
Other
8.82k stars 2.05k forks source link

API to Get all skin names array of Spine Animaton #16740

Open finscn opened 9 months ago

finscn commented 9 months ago

Use Case

sometimes, develovpers need. get a string-array of all skin-names , then random pick one to use .

Problem Description

目前cocos 有一个api spine.skeletonData.getSkinsEnum(); 但是返回的是一个 key-value , 而且是双向的 并不便于使用.

我自己在项目里实现了一个这个方法

    getAllSpinSkins (spine: sp.Skeleton): string[] {
        const skins = (spine.skeletonData.skeletonJson as any).skins as any[];
        const nameList = skins.map((skin) => skin.name as string);
        return nameList;
    }

希望cocos能自带, 这样开发者只要 用 spine.getAllSkins() 就可以了

Proposed Solution

No response

How it works

No response

Alternatives Considered

.

Additional Information

No response

finscn commented 5 months ago

@minggo @bofeng-song