How to get Sprite Manager by name

Hello Everyone,

I know that scene has different methods to get specific Mesh or Material by Name.
For instance: scene.getMeshByName, scene.getMaterialByName…

Is there any way can get the Specific “Sprite Manager” named by " Sprite_1" ?
Since I would like to change the “URL Source” of Sprite Manager after taking action like click event.

looking forward to replay.
Thank you.

Welcome aboard!

The scene does not keep track of the sprite managers, but as you must create them yourself by doing a new SpriteManager(...) call you can store the pointer received by this call somewhere (in a map for eg) to reuse later.

Hi Evgeni_Popov,

Thanks for your reply. It is a good idea to store SpriteManager in the Map.
And I’ve done that successfully.

However, is it possible to change the ‘original imgUrl’ in spriteManager?
(Eg. var spriteManager = new BABYLON.SpriteManager('Sprite' , imgUrl, 1, 142, scene);

Because I’d like to change different colors of images in the SpriteManager on click

You can’t change the imgurl parameter afterward but you can change the texture used by the sprite manager by calling spritemanager.texture.updateURL(…).

Thank you very much !!
It’s useful about the``spritemanager.texture.updateURL (…).

There are a lot of fun and explorations in babylonjs.
And it’s really great in this Forum.

1 Like