# Loading 3D Avatars

{% hint style="info" %}
These examples have been tested in Unity 2020.3LTS and newer versions.
{% endhint %}

## Loading one 3D avatar at runtime

The `AvatarLoadingExample.cs` script demonstrates how to load **one avatar** at runtime.&#x20;

{% hint style="info" %}
**Scene and Code**\
`Assets/Samples/Enoch Avatar Loader/1.0.0/AvatarLoading/AvatarLoadingExample`
{% endhint %}

1. Open and play the AvatarLoadingExample Scene. The example loads an avatar (and includes a Debug Log panel described below).&#x20;
2. Open the **RuntimeExample.cs script**, which loads the avatar as follows.
   * Creates an instance of AvatarLoader: `var avatarLoader = new AvatarObjectLoader();`
   * Defines the `OnCompleted()` callback for the `AvatarObjectLoader` this is called when loading has successfully completed.&#x20;
   * Adds an Avatar Configuration to the `AvatarObjectLoader` from Assets > Plugins > ReadyPlayerMe > Resources > Data > AvatarConfigurations.
   * Calls `LoadAvatar()` with the URL for the avatar to load. This operation will download, import, and load the avatar model into the Scene.

## Loading multiple 3D avatars at runtime

This code sample demonstrates how to load **multiple avatars** at runtime.&#x20;

{% hint style="info" %}
**Scene and Code**\
`Assets/Samples/Enoch Avatar Loader/1.0.0/MultipleAvatarLoading/MultipleAvatarLoadingExample`
{% endhint %}

1. Open and play the **MultipleAvatarLoadingExample** Scene. The example loads several avatars (and includes a Debug Log panel described below).&#x20;
2. Open the **MultipleAvatarLoadingExample.cs script**.
   * Notice that there is only one avatar URL.
   * Loading works in the same way as for one avatar and is repeated for every avatar to load.
   * The variations in the avatar are created by using a list of different configurations that are applied in `OnCompleted() -> OnAvatarLoaded()` after the avatar has been loaded.

## Debug panel

{% hint style="info" %}
**Code**\
`Assets/Plugins/Enoch/Examples/Runtime Example/Runtime Debug Panel`
{% endhint %}

The **Debug Panel** displays the avatar loader log output while the Scene is running in the Unity Editor or on a target device.&#x20;

You can pause or hide the Debug Panel while playing, or select the Runtime Test game object and disable the DebugPanel(Script) component in the Inspector.&#x20;

{% hint style="info" %}
The Debug Panel is provided to assist in troubleshooting avatar loading issues on the device. Include the information contained in the log output with any support queries that you submit via our Technical Support channels.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://enoch-app.gitbook.io/enoch/developers-integration-guide/unity-integration/code-examples/loading-3d-avatars.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
