Loading 2D Avatars
Code sample that demonstrates how to load 2D avatars at runtime.
Last updated
Code sample that demonstrates how to load 2D avatars at runtime.
Last updated
Open the Unity Package Manager and find the Ready Player Me Core Package.
You can find the code samples on the package manager's right side. Find the AvatarRenderSamples and click Import.
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 in a heads-up display or using it as a button icon.
This example has been tested in Unity 2020.3LTS and newer versions.
Scene and Code
Assets/Samples/Ready Player Me Core/[VERSION_NUMBER]/AvatarRenderSamples/MultipleRenders
Open and play the SingleRender/AvatarRenderExample Scene.
Open the AvatarRenderExample.cs script.
Notice that a 2D render uses the same avatar URL as the 3D render of the same avatar.
Creates an instance of AvatarRenderLoader
.
Defines the OnCompleted()
callback for the AvatarRenderLoader
; this is called when loading has successfully completed and creates a sprite for the avatar.
Calls LoadRender()
with the URL for the avatar to load, the type of scene to render, the name of the target blend shape mesh, and the blend shapes.
See the AvatarRenderLoader API documentation for details on LoadRender()
arguments.