• RuntimesUnity
  • Preload skins with addressables in runtime?

Hello! In our game we have characters with cosmetic skins. Since yesterday we had the skins into 1 single texture, but it was getting bigger and bigger so we decided to have each skins in a different texture and load them with addressables in runtime, so I included the Addressables Extensions and the On-Demand Loading Extensions packages in order to do that. Everything works perfectly, awesome work on you side <3, I can see how the live graphic memory has decreased from 340MB to 64-96MB, which is nice, but the thing is that when switching skins for the first time you can see the blurry LoadingPlaceholderAssets for like a fraction of second, I guess due to the textures not yet loaded.

So my question is: is there a way to preload in background, let's say, all the skins for example when the player enters the customization menu, that the package provides? Or is this something we should take care by ourselves? I couldn't find anything on the documentation (I guess it's because the package it quite new, still experimental) and I am not an experienced user with addressables (yet), so right now I just follow the instructions here.

Thanks a lot!

    Related Discussions
    ...

    @xalbertus Thanks for your kind words, glad the package helped!

    xalbertus So my question is: is there a way to preload in background, let's say, all the skins for example when the player enters the customization menu, that the package provides? Or is this something we should take care by ourselves?

    You will need to trigger loading in some way.
    One way is to call AtlasAssetBase.RequireTexturesLoaded(material, ref overrideMaterial) like it's called by SkeletonRenderer.HandleOnDemandLoading() here. You might also want to call atlasAsset.BeginCustomTextureLoading(); and atlasAsset.EndCustomTextureLoading().

    Other than that, you could assign skins or attachments at a skeleton that you want to preload textures for, and call skeletonRenderer.LateUpdateMesh() once. Afterwards could immediatley switch back to the actual skins, or use a hidden dummy-skeleton just for preloading.