I need to create new Sprite Node with picture load from distant URL, however It doesn’t work.
That is my code:
// distant load photograph
assetManager.loadRemote<ImageAsset>(photo_url, (err, imageAsset) => {
const spriteFrame = SpriteFrame.createWithImage(imageAsset);
const newNode = new Node()
// add new Sprite element
newNode.addComponent(Sprite)
const sprite = newNode.getComponent(Sprite)
// assign sprite body to the brand new Sprite Node
sprite.spriteFrame = spriteFrame
// set node content material measurement
const newNodeTransform = newNode.getComponent(UITransform)
newNodeTransform.setContentSize(200, 200)
// add to different node
this.photoBorder.node.guardian.addChild(newNode)
});
Please assist me resolve this downside
Thanks very a lot!
Is the picture handle appropriate? Is the picture format?
Or add this code: newNode.layer = Layers.Enum.UI_2D;