Spine with multiple json files

In Cocos Creator 3.8.3, I have a spine asset which consist of one spine.atlas file, one spine.png file and multiple json files like spine1.json, spine2.json and spine3.json.

I am encountering error when importing the spine asset due to cocos editor tries to find spine1.atlas, spine2.atlas and spine3.atlas. I was able to do this in cocos 2.4 by altering spine-meta.js in the engine but I wasn’t able to locate the same file or its counterpart in 3.8.3. Is there any way I can customize the path of the atlas to load?

Error messages:
[Assets] Importer exec failed: /Users/user/Documents/Projects/Cocos/TestSpine/assets/spine1.json
[Assets] Can not find /Users/user/Documents/Projects/Cocos/TestSpine/assets/spine1.atlas

Hi, if it is impossible please let me know. Thanks.

could you please provide the demo for us to check?

Please check on this demo. You will be able to see the following errors when opening the project.

[Assets] Importer exec failed: /Users/user/Documents/Projects/Cocos3.0/TestSpineCyka/assets/spineboy-pro_atlas_gun.json

[Assets] Can not find /Users/user/Documents/Projects/Cocos3.0/TestSpineCyka/assets/spineboy-pro_atlas_gun.atlas

[Assets] Importer exec failed: /Users/user/Documents/Projects/Cocos3.0/TestSpineCyka/assets/spineboy-pro_atlas_portal.json

[Assets] Can not find /Users/user/Documents/Projects/Cocos3.0/TestSpineCyka/assets/spineboy-pro_atlas_portal.atlas

What I want to achieve is to detect the file name of the json file with ‘_atlas’ then get the string before the ‘_atlas’ text and load the atlas file with the string.

If the above mentioned is achieved in this demo, when the json file spineboy-pro_atlas_portal.json is loaded, the ‘_atlas’ string in the file name is found so it will load spineboy-pro.atlas instead of spineboy-pro_atlas_portal.atlas.

I was able to customize this in cocos 2.4.7 by changing the contents in spine-meta.js but I could not find its counterpart in cocos 3.8.3.

en , How do you custom this in Cocos 2.4.7 to make it available?

Sorry for the late reply. I was able to achieve this by altering the searchAtlas function in spine-meta.ts in Cocos 2.4.7, I modify the value of the path variable with conditions.

Hi, any update on this?

Hi @Tom_k , any update on this?

You cant not custom the path of the atlas to load in 383. sorry for that.

noooooooooo
NOOOO

could you please provide the email to me?

I think you can just clone the spine.atlas file to multiple files and rename those files to spine1.atlas, spine2.atlas,… That is a work around for me

Thank you, I am aware of this approach and it is what I am trying to avoid as there is no point having multiple atlas files when they have the same content.

1 Like

I am just aware this approach doesn’t work on native Android build. It will cause the game crash in cocos ver 3.8.3

spine-cocos2dx.cpp:110: virtual void spine::Cocos2dTextureLoader::load(spine::AtlasPage &, const spine::String &): assertion "(texture)!=(nullptr)" failed

Do your team aware of this issue @Tom_k ?

This is the way to implement to cause the crash on Android?

Yes, the android crash with the error I post above, the web version work fine

We will fixed it in 386. Currently you can create one individual png and atlas for each json.

1 Like