Load Avatars [Deprecated]

Load 3D and 2D avatars into your Unity Scene.

In this guide, you learn how to load avatars into your Unity Scenes.

Load 3D Avatars

You can load full-body and half-body avatars into your Unity game. For both types of avatars you can follow the same procedure.

  1. Create an instance of the AvatarLoader.

  2. Call the LoadAvatar() method with an avatar URL. The example uses a URL from the demo Avatar Creator https://demo.readyplayer.me. You will later learn how to retrieve an Avatar URL directly in your game.

var avatarUrl = "https://api.readyplayer.me/v1/avatars/632d65e99b4c6a4352a9b8db.glb";
AvatarLoader avatarLoader = new AvatarLoader();
avatarLoader.LoadAvatar(AvatarURL); 

3. Receive the GameObject of the avatar in CompletionEventArgs of the OnCompleted callback.

See the code below for the completed example. See the API Reference for a complete list of callbacks of the AvatarLoader.

You can also find the code below in the Assets\Plugins\Ready Player Me\Examples\Runtime Example\RuntimeExampleScene and script.

using UnityEngine;

namespace ReadyPlayerMe
{
    public class RuntimeExample : MonoBehaviour
    {
        //Demo Avatar URL
        [SerializeField]
        private string avatarUrl = "https://api.readyplayer.me/v1/avatars/632d65e99b4c6a4352a9b8db.glb";

        private GameObject avatar;

        private void Start()
        {
            ApplicationData.Log();
            var avatarLoader = new AvatarLoader();
            avatarLoader.OnCompleted += (_, args) =>
            {
                avatar = args.Avatar;
                AvatarAnimatorHelper.SetupAnimator(args.Metadata.BodyType, avatar);
            };
            avatarLoader.LoadAvatar(avatarUrl);
        }

        private void OnDestroy()
        {
            if (avatar != null) Destroy(avatar);
        }
    }
}

Load 2D Avatars

You can load a 2D render of your avatar using the AvatarRenderLoader class which obtains a rendered image of your avatar via the Render API.

  1. Create an instance of AvatarRenderLoader.

  2. Call the LoadRender() method, passing the required arguments.

AvatarRenderLoader avatarRenderLoader = new AvatarRenderLoader();
avatarRenderLoader.LoadRender(url, scene, blendShapeMesh, blendShapes);

See the code below for a complete example. See the AvatarRenderLoader API Reference to learn more about AvatarRenderLoader and the function arguments.

You can find a complete example usage of this code in the Assets\Plugins\Ready Player Me\Examples\AvatarRender Example\AvatarRenderExample scene and script.

Save avatars as NPCs in your project

The easiest way to save avatars in your project and package them with your build is using the Avatar Loader.

The Avatar Loader lets you download and save an avatar in your project in the Unity Editor.

  1. Paste your avatar URL (or shortcode) into the Avatar URL or Shortcode field.

  2. Optionally, check Use Eye Animations. This will add a component to the avatar GameObject.

  3. Optionally, check Voice To Animation. This will add a component to the avatar GameObject.

  4. Click Load Avatar into the Current Scene.

  5. Your avatar loads into the current Scene at position (0,0,0).

Last updated

#168: React Guides

Change request updated