Avatar caching

Store avatar assets and data locally.

Avatar Caching

The Ready Player Me SDK provides an avatar caching functionality. If avatar caching is enabled, every time an avatar is loaded, it is also stored in the local storage. If you subsequently try to load the avatar again, the system will check if the avatar needs to be updated, and if so, it will download and save the updated avatar locally. If the avatar does not need to be updated, the avatar will be loaded from the local storage.

If a Ready Player Me user makes a change to an existing avatar, such as altering the hairstyle, then the avatar needs to be redownloaded even if it is cached locally. This ensures that the application loads the most up-to-date avatar.

Avatar caching is available at runtime and includes support for Avatar Configurations.

Enable caching

Avatar caching is disabled by default. To enable avatar caching, do the following:

  1. Open Edit > Project Settings.

  2. In the Game section, select Ready Player Me.

  3. Check Enable Avatar Caching.

Automatic cache cleanup

To prevent the local storage from being overflown with unneeded saved avatars, there is an option to automatically clean up the memory when new avatars are loaded. The cleanup will be done based on the limit of the stored avatars and the avatar's last request date.

To enable the automatic cache cleaning, from the same ReadyPlayerMe settings enable the Enable Automatic Avatar Cache Cleaning checkbox, and set the desired limit in the Cached Avatar Limit field.

Manual avatar cache operations

If there is a need for more control over the avatar cache, the SDK provides useful functions for manual cache management.

Stored avatar data location

Downloaded avatar data is stored based not only on the avatar ID but also on the assigned Avatar Configuration parameters. This means that multiple instances of an avatar's data may exist in the cache at any given time.

Avatar data is stored at

<Persistent Data Path>/Avatars/<avatar ID>/<Avatar Config parameters hash>/

Cached avatar data use and updating

  • At runtime, when caching is enabled, the avatar loader checks the state of the avatar on the Ready Player Me server before downloading. If the avatar has not been modified since it was last stored in the client-side cache, the avatar data for the given avatar ID and Avatar Config parameters are loaded from the cache.

  • If changes were made to the avatar on the Ready Player Me server, the client-side cache for the given avatar ID is cleared and recreated when subsequent load requests are made.

  • If the avatar download is interrupted or aborted during data transmission, any corrupt client-side cache data is deleted and recreated the next time the avatar is downloaded.

Last updated