Is there any way to hide images while they are loading?

Hi guys,

Currently, the texture/sprite is displayed as white rectangle until it’s fully loaded. I would like to hide it (or make transparent) instead and show the image when it’s 100% loaded. Is there any simple way to do it?

image

Thanks

1 Like

Hi @Taras,

You could either select preloaded on the texture in the editor, or leave all of those entities disabled/transparent in the editor and enable them after the assets have finished loading via script. If it is used often, it makes sense to have the loading done before the Playcanvas loading screen has finished.

If you would like to avoid this check out this bit of the user manual:

https://developer.playcanvas.com/en/user-manual/assets/preloading-and-streaming/

Here you could write a script that checks for the assets that have certain tags to be loaded, and once they are, enable the desired entities.

2 Likes

Hello guys!

Have the same question - why sprites do use the while square placeholder while their textures are loading? Why not transparent/invisible square?
In streaming section of the documentation https://developer.playcanvas.com/en/user-manual/assets/preloading-and-streaming/#streaming the robot model are streaming smoothly: there are no placeholders visible until the model is loaded, it just appears from nowhere. So, why don’t you do the same for sprites?

Of course, I understand that showing a placeholder is important on development phase (at least for quick discovering missing textures), but once the project is released, the white placeholder square is useless IMHO.
Having such checkbox in the project settings would be nice.

1 Like

That’s an interesting question. Image elements have a default texture when no texture/sprite/etc is assigned to them. We just haven’t got the logic to remove the default texture if a texture/sprite/etc is assigned.

This could be something that could be patched/added on a per project level by overriding the default texture to be transparent.

eg https://playcanvas.com/project/785530/overview/changing-default-image-texture

Also, please add a feature request to the engine repo if you would like to see something more official : https://github.com/playcanvas/engine/issues

:slight_smile:

Side note: I generally recommend having a spinner for images/elements that haven’t been loaded yet for a smoother user experience.

1 Like