Hi there,
What I am trying to do is dynamically load external spritesheets and replace current texture atlas.
Loading and replacing is only successfull on sprite components.
I am wondering why this won’t work on sprites assigned to an element component.
// initialize code called once per entity
ReplaceTextureAtlas.prototype.initialize = function () {
this.entity.button.on("click", function () {
// replace sprite atlas texture
this.app.root.findByName("Sprite").sprite._clips['Clip 1']._sprite._atlas._texture = LoadVisuals.awardWin.resources[0];
// replace element sprite atlas texture
this.app.root.findByName("Element Sprite").element._image._sprite._atlas._texture = LoadVisuals.awardWin.resources[0];
console.log(this.app.root.findByName("Element Sprite").element);
}, this);
};
Here’s a test project to show what is (not) going on.
https://playcanvas.com/project/1058525/overview/replace-sprite-textureatlas
What am I missing?
Thanks.