Links

Examples

Load an avatar at runtime example

You can find the sample code in the Assets/Plugins/Ready Player Me/Examples/ folder of the Ready Player Me Unity SDK package.
The sample demonstrates how to load an avatar at runtime.
You create an instance of AvatarLoader and call theLoadAvatar() method with the URL of the avatar to load. This operation will download, import, and load the avatar model into the Scene. You can find the code for this example in the Runtime Example/RuntimeExample.cs script.
  • Open and play the Runtime Example/RuntimeExample Scene included in the Ready Player Me Unity SDK.
This example includes a Debug Panel to display the avatar loader log output while running the Scene in the editor or on a target device. You can pause or hide the the Debug Panel while playing, or select the Runtime Test game object and disable the DebugPanel(Script) component in the Inspector.
Ready Player Me updates a user's avatar while keeping the original URL. If you customize an existing avatar, or change the body type, these changes will be reflected via the same URL.
The examples include test avatar URLs. You can create personal avatar .glb URLs or short codes at https://readyplayer.me.
The Debug Panel is provided to assist troubleshooting avatar loader issues on device. The information contained in the log output should be included in any support queries submitted via our Technical Support channels.
The examples have been tested in Unity 2019LTS and newer versions of the Unity3D game engine.

Loading Multiple Avatars

You can load multiple avatars from a list of avatar URLs as demonstrated in the included Example/RuntimeExampleMultiple.cs script.
  • Open and play the Runtime Example/RuntimeExampleMultiple Scene included in the Ready Player Me Unity SDK.

Load an avatar render example

You can find the sample Scene and code in the Assets/Plugins/Ready Player Me/Examples/AvatarRender Example/ folder of the Ready Player Me Unity SDK package.
  • Open and play the AvatarRender Example/AvatarRenderExample Scene included in the Ready Player Me Unity SDK.
This example demonstrates how to request an avatar render image via the Render API and apply the result to a UI sprite. This approach may be useful for showing a profile picture of an avatar within a heads-up display or as a button icon.
Create an instance of AvatarRenderLoader and call theLoadRender() function. This function takes the following arguments.
Parameter
Type
Description
url
string
URL of the avatar you wish to render. This is the same URL used to load the avatar model.
scene
AvatarRenderScene
Type of scene to render. See Render API documentation.
blendShapeMesh (optional)
string
Target blend shape mesh name. Required if you wish to apply custom blend shape weights to the render.
blendShapes (optional)
Dictionary<string, float>
Blend shape name and weight to apply to the avatar render.
You can find the code for this example in the Assets/Plugins/Ready Player Me/Examples/AvatarRender Example/AvatarRenderExample.cs script.
For more information on the parameters and format of a valid render request, refer to the Render API documentation.

Avatar mesh LOD example

You can find the sample scene and code in the Assets/Plugins/Ready Player Me/Examples/AvatarLod Example/ folder of the Ready Player Me Unity SDK package.
This example demonstrates how to load multiple levels of detail (LOD) for avatar meshes and configure distance based render optimisation. By enabling level of detail, Unity displays the appropriate LOD level for the rendered avatar based on the avatar's distance from the camera.
The code related to avatar loading and LOD configuration can be found in:
Assets/Plugins/Ready Player Me/Examples/AvatarLod Example/AvatarLodExample.cs
Using the Avatar API and Avatar Configurations, this approach downloads multiple avatar LODs, extracts the avatar meshes and configures the final avatar with LOD support enabled.
This example does not support Avatar Configurations with TextureAtlas=None.

Avatar Creator integration for iOS and Android (WebView)

This example demonstrates how to integrate a Ready Player Me WebView into a Unity Scene. This feature lets users create Ready Player Me avatars directly in a WebView browser displayed in Unity at runtime on mobile devices.
You can find the sample code in the WebView Example/WebViewExample.cs script.
To try this out:
  1. 1.
    Include the WebView Example/WebViewExample Scene in a mobile platform build.
  2. 2.
    Open the Scene on the device and click Display WebView.
  3. 3.
    A WebView loads and you can create a Ready Player Me avatar.
  4. 4.
    Once avatar creation is complete, the WebView closes and the avatar is loaded into the Scene.
The default partner domain is always demo and it provides both full-body and half-body avatars.
If you are a Ready Player Me partner, you can edit the target URL to use your partner domain via Open Ready Player Me > Settings.

Avatar Creator integration for Mac and Windows

Download and open the sample Unity Project from GitHub: https://github.com/readyplayerme/Unity-Vuplex-Example
Follow the steps in the Readme and learn how it works and how it is set up.

WebGL Example

The Avatar Creator can also be integrated into your WebGL Unity Project. It requires some extra steps to set up the communication between the Avatar Creator and your Unity application.
Download and open the sample Unity Project from GitHub: https://github.com/readyplayerme/Unity-WebGL-Example
Follow the steps in the Readme and learn how it works and how it is set up.