How to load a Spine asset without changing the loader's baseURL

Hello,

I am developing a game which uses Spine. When I try to load the Spine assets it fails to load the images from the atlas because it always loads them relative to the index, not the atlas URL. So if my atlas was at “spine/robot/small.atlas” and the image was “spine/robots/small.png” it would try to download the file at “spine.png” without the “spine/robots/” base.

I can set the “baseURL” property of the scene.load to be “spine/robots/”, but then all other assets I am trying to load which are not in that folder will fail because their paths will be prefixed with “spine/robots/”.

I tried setting the baseURL just for the duration of the load:

scene.load.baseURL = "spine/robots/";
scene.load.spine("smallRobot", "small.json", "small.atlas");
scene.load.baseURL = "";

However, it seems that the baseURL is applied asynchronously because neither the JSON nor atlas get loaded this way as they do not have “spine/robots/” as part of their URL.

I did notice that I can set scene.load.path instead of baseURL, and that gets applied, but only to the small.json and small.atlas URLs, the path to the image that comes from the atlas file will not be prefixed with this path.

How can I make it so that I can set the baseURL per asset I am loading without affecting other assets?

Thanks in advance.

Maybe this and this will help you.

I did try that and found it not to work. What I tried specifically was:

scene.load.path = 'spine/robots/';
scene.load.spine(id, 'small.json', 'small.atlas');
scene.load.path = '';

This loaded the small.json and small.atlas correctly, but still tried to load the references in the atlas without the path prefix. What I ended up doing to fix this is to set the path in the config of the SpineFile that gets created as part of the load operation:

scene.load.spine(id, 'small.json', 'small.atlas');
scene.load.list.entries[scene.load.list.size - 1].multiFile.config.path = 'spine/robots/';