Hello,
I am loading a CDN based presigned URL through assetManager.loadRemote. I am using cocos 3.8.3. The url contains a png. However the URL doesnt end with “.png”, hence I am passing the extension as mentioned in the doc.
My code is as follows -
if ( url.includes("png"))
{
ext = ".png";
}
assetManager.loadRemote<ImageAsset>(url, {ext: `${ext}`}, function (err, imageAsset) {
if (err) {
reject(err);
} else if (imageAsset instanceof ImageAsset) {
// Convert ImageAsset to Texture2D
const texture = new Texture2D();
texture.image = imageAsset;
resolve(texture);
} else {
reject(new Error("Loaded asset is not an ImageAsset"));
}
});
I verified the ext is “.png”. It is able to load it and it does assign - texture.image = imageAsset;. However when I later do this -
// Create a SpriteFrame and assign the texture
const spriteFrame = new SpriteFrame();
spriteFrame.texture = texture;
this.sprite = this.node.getComponent(Sprite);
this.sprite.spriteFrame = spriteFrame;
It seems to assign it. However my node’s sprite’s spriteFrame is still null. It doesnt get set. What could I be doing wrong ? Thanks in advance for your help!