AvatarLoader [Deprecated]

The AvatarLoader class is used for loading and downloading avatar models and configuring the output.

Properties

PropertyTypeDescription

AvatarConfig

AvatarConfig

Avatar Configuration instance used when downloading avatars.

AvatarImporter

IAvatarImporter

Avatar Importer instance used for importing the GLB model.

Public Methods

MethodReturnsDescription

LoadAvatar(string url)

void

Initiates avatar download and import operations. Takes an Avatar URL as a parameter.

Cancel()

void

Cancels the current avatar loading process. Fires OnFailed event with FailureEventArgs as OperationCancelled.

Events

EventEventArgsDescription

OnCompleted

CompletionEventArgs

Called upon avatar loader success.

OnFailed

FailureEventArgs

Called upon avatar loading failure.

OnProgressChanged

ProgressChangedEventArgs

Called upon avatar loader progress change.

Example

using UnityEngine;

namespace ReadyPlayerMe
{
    public class RuntimeExample : MonoBehaviour
    {
        [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);
        }
    }
}

Last updated

Change request #130: Asset API