> For the complete documentation index, see [llms.txt](https://enoch-app.gitbook.io/enoch/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://enoch-app.gitbook.io/enoch/developers-integration-guide/unreal-engine-integration/load-avatars.md).

# Load Avatars

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

* [**Load 3D Avatars**](#load-3d-avatars)
* [**Load 2D Avatars**](#load-2d-avatars)
* [**Save Avatars in your Unity Project**](#save-avatars-as-npcs-in-your-project)

## 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 `AvatarObjectLoader`.&#x20;
2. Call the `LoadAvatar()` method with an avatar URL. The example uses a URL from the demo Avatar Creator <https://demo.enoch-avatar.app>. You will later learn how to retrieve an Avatar URL directly in your game.

```csharp
var avatarUrl = "https://api.enoch-avatar.app/v1/avatars/632d65e99b4c6a4352a9b8db.gltf";
AvatarObjectLoader avatarLoader = new AvatarObjectLoader();
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](/enoch/api-references/unity-sdk.md) for a complete list of callbacks of the `AvatarLoader`.&#x20;

{% hint style="info" %}
You can also find the code below in the `Assets\Plugins\Enoch Avatars\Examples\Runtime Example\RuntimeExample`Scene and script.
{% endhint %}

```csharp
using Enoch.AvatarLoader;
using Enoch.Core;
using UnityEngine;

namespace Enoch
{
    public class AvatarLoadingExample : MonoBehaviour
    {
        //Demo Avatar URL
        [SerializeField]
        private string avatarUrl = "https://api.enoch-avatar.app/v1/avatars/632d65e99b4c6a4352a9b8db.gltf";

        private GameObject avatar;

        private void Start()
        {
            ApplicationData.Log();
            var avatarLoader = new AvatarObjectLoader();
            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`](broken://pages/BflcEp4S6glE8bnltEvk) 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.

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

See the code below for a complete example. \
See the [AvatarRenderLoader API Reference](/enoch/api-references/unity-sdk.md) to learn more about `AvatarRenderLoader` and the function arguments.

{% hint style="info" %}
You can find a complete example usage of this code in the `Assets/Samples/Enoch Avatar Loader/1.0.0/AvatarLoading/AvatarLoadingExample`  scene and script.
{% endhint %}

## **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. Launch the Avatar Loader window by choosing **Enoch Avatars > Avatar Loader**. ![](/files/y9HrZQs3Jz9x6bzxLMBx)
2. Paste your avatar URL (or code) into the **Avatar URL or code** field.
3. Optionally, check **Use Eye Animations**. This will add a component to the avatar GameObject.
4. Optionally, check **Voice To Animation**. This will add a component to the avatar GameObject.
5. Click **Load Avatar into the Current Scene**.&#x20;
6. Your avatar loads into the current Scene at position (0,0,0).&#x20;
7. The avatar prefab is stored in a new folder (name = avatar ID) in `Assets > Avatars`.![](/files/s3q54OYPbheKI1icCYRx)
