Links

API Reference

Reference for the Ready Player Me SDK.

Dependencies

Dependencies are already included in the .unitypackage file. If you are using an older or a newer version of these dependencies, back up your project before making changes.

Class Reference

AvatarLoader

This main class is used for loading and downloading avatar models and configuring the output.
public void LoadAvatar(string url)
  • Initiates avatar download and import operations.
public event EventHandler<FailureEventArgs> OnFailed
  • Called upon avatar loader failure.
public event EventHandler<CompletionEventArgs> OnCompleted
  • Called upon avatar loader success.
public event EventHandler<ProgressChangedEventArgs> OnProgressChanged
  • Called upon avatar loader progress change.
public IAvatarImporter AvatarImporter
  • Avatar Importer instance used for importing the GLB model.
public void Cancel()
  • Cancels loading and fires OnFailed event with FailureEventArgs as OperationCancelled.
public AvatarConfig AvatarConfig
  • Avatar Configuration instance used when downloading avatars. See Avatar Configuration for more details.

SDKLogger

The SDKLogger prints logs about the current operation and the status of the avatar loading process. It is enabled by default. Logging can be disabled by setting logEnabled to false.
SDKLogger.AvatarLoaderLogger.logEnabled = false;

WebView (Mobile only)

The component that loads the In-Unity Browser targets the Ready Player Me website and is in the WebViewCanvas prefab.
To use WebView you can create the WebView Canvas by selecting GameObject/UI/WebView Canvas or right-clicking in the Hierarchy window and selecting UI/WebView Canvas.
public void CreateWebview()
  • Creates the WebView window and loads the Ready Player Me website.
public void SetScreenPadding(int left, int top, int right, int bottom)
  • Sets the screen padding of the WebView window. Default is 0 for all sides.
public Action<string> OnAvatarCreated
  • Event to call when an avatar is created. Receives GLB URL.
public void SetVisible(bool visible)
  • Sets the visibility of the WebView.
public void ClearAvatarData()
  • Clears avatar data from the WebView local storage and reloads the Ready Player Me page for new avatar creation.
If the cache is cleared, then the next time you open Ready Player Me in the WebView, your previous avatar will not be there, and you will start from the beginning of the avatar creation process.
public bool KeepSessionAlive { get; set; } = true;
  • If set to false, clears stored avatar data after the avatar creation is finished, or when the WebView is destroyed. By default, this is set to true.

Avatar Caching

Runtime avatar cache utilities are contained within the AvatarCache class. These provide access to query and clear the current cache data. The following public methods are available:
public static bool IsCacheEmpty()
  • Return true if no avatars present in the persistent cache.
public static void Clear()
  • Clears all the avatar data from the persistent cache.
public static void ClearAvatar(string guid)
  • Clears all the avatar data for a specific avatar guid from the persistent cache.
public static long GetAvatarCount()
  • Returns total Avatars stored in persistent cache.
public static int GetCacheSize()
  • Returns total size of all avatars stored in persistent cache. The value returned is in bytes.

Extras

The SDK comes with extra components to help you set up your avatar.
You can add these components to your avatar object from the component menu or at runtime using Unity's AddComponent() method.

EyeAnimationHandler

Rotates and blinks the eyes of the avatar randomly.
You can set the blink delay in the component Inspector.

Variables

public float BlinkSpeed
  • How fast the eyes blink in seconds.
public float BlinkInterval
  • Frequency of eye blinking in seconds.

Example

private void AvatarLoadedCallback(GameObject avatar)
{
avatar.AddComponent<EyeRotationHandler>();
}

VoiceHandler

Uses microphone feedback to animate the mouthOpen blend shape based on the amplitude of the voice. The animation will have a 1-second delay due to the minimum recording length.

Variables

public AudioClip AudioClip
  • Audio Clip to play.
public AudioSource AudioSource
  • Audio Source that will play the provided audio. If not assigned in the Inspector, it will be created on the same object as the VoiceHandler component.
public AudioProviderType AudioProvider
  • Enum type of audio provider. Microphone or Audio Clip.

Methods

public void PlayCurrentAudioClip()
  • Plays the current Audio Clip.
public void PlayAudioClip(AudioClip audioClip)
  • Sets the current Audio Clip with the given parameter and plays it.

Examples

private void AvatarLoadedCallback(GameObject avatar)
{
avatar.AddComponent<VoiceHandler>();
}