Error in adding spine from remote

Error in adding spine from remote.
Following this link : https://docs.cocos.com/creator/3.6/manual/en/asset/spine.html?h=skeletal%20animation%20assets

also found this https://discuss.cocos2d-x.org/t/how-to-dynamically-load-spine-animations-from-a-server/46117 on discuss but it is of no use

@ccclass("spineAnim")
export class spineAnim extends Component {
    start() {
        let image = "http://127.0.0.1:8887/maskLeft.png";
        let ske = "http://127.0.0.1:8887/maskLeft.json";
        let atlas = "http://127.0.0.1:8887/maskLeft.atlas";

        assetManager.loadRemote(image, (error, texture: Texture2D) => {
            if (error) {
                console.log(error);
            } else {
                assetManager.loadAny(
                    [
                        { url: atlas, ext: ".txt" },
                        { url: ske, ext: ".txt" },
                    ],
                    (finished, total, item) => {
                        console.log(finished, total, item);
                    },
                    (err, imageAsset) => {
                        if (err) {
                            console.log(err);
                        } else {
                            console.log("texture", texture);
                            console.log("JSON", imageAsset[1]);
                            console.log("Atlas", imageAsset[0]);
                            let asset = new sp.SkeletonData();
                            asset.skeletonJson = imageAsset[1];
                            asset.atlasText = imageAsset[0];
                            asset.textures = [texture];
                            asset.textureNames = ["maskLeft.png"];
                            this.node.getComponent(sp.Skeleton).skeletonData = asset;
                        }
                    }
                );
            }
        });
    }
}

Assets are loaded successfully but the error is:

skeleton-texture.ts:50 Uncaught TypeError: this.getRealTexture(…).setFilters is not a function
at SkeletonTexture.setFilters (skeleton-texture.ts:50:36)

Cocos version 3.6.2

Hi, I tested with the code you provided and it works fine, but there is a mistake in your code.

  • The object loaded by assetManager.loadRemote is an imageAsset object, not a texture2D object, so you need to create a texture2d object and use the imageAsset data to assign it.

I will provide the test code and the test project

  1. download the code package, open the project with visual studio code, and install the live server extension on visual studio code, and set the remote folder to the local server’s remote load path address
  2. In the code, first load the image object of texture and create texture2D dynamically, initialize the texture2D object with the image data.
  3. load the ske data and json data, and fill the spine’s SkeletonData data, and set the spine’s animation.

Finish the remote loading of spine by the above steps




NewProject_1.zip (1.4 MB)

Thank You :grinning:

Why this same is not working for local storage? @muxiandong
Like loading spine from localStorage for Android.
Creator 3.5.2
Getting this error

Can not render dynamic created SkeletonData