# Setup

{% hint style="success" %}
Don't forget to check out the Demo Scene, which has a working system ready to check out.
{% endhint %}

## 1. Create Layers

Each portrait must have its own layer. I suggest naming them "Portrait0", "Portrait1", "Portrait2" and so on.

Create new Layers for each of your portraits. Open the Layers drop down and click the "Edit Layers" option at the bottom of the list to create new layers.

<figure><img src="/files/6mWCTfdjzaWLkF62Gf1m" alt="" width="367"><figcaption></figcaption></figure>

{% hint style="warning" %}
If you plan on using the **Portraits Realtime Color** system, which is optional, you need to also create a layer for that. Call it "ColorSampler".
{% endhint %}

## 2. Bring in Portrait Avatars

The `Portraits/Prefabs` folder has a `Portrait Avatars Parent` object, which includes `PortraitAvatars` component on it.&#x20;

Bring this into your scene as a child of player object. Portrait Avatars instantiated during the game will be children of this object.

### Populate the Player Avatar Prefab

In the **Required** section of the `PortraitAvatars` component, you'll need to provide your Potrait Avatar prefab. This is avatar object which will be spawned into the scene. Check the demo scene to view the "Portrait Avatar - Demo" object. This object should contain a `Portrait` component.

{% hint style="success" %}
The "Portrait Avatar" object in the Prefabs folder can be duplicated and used as a starting point for your own portraits. Try getting the system working with a duplicated version of this before making a customized Avatar.
{% endhint %}

### Set the Available Layers

In the Available Layers drop down, select only the layers you created previously. These are the layers which will be assigned to each portrait. Note that your game can only have as many portraits as there are available layers.

### Set your Avatar Local Spawn Position

The Portrait Avatar Prefab you select will be instantiated at this position, local to the Portrait Avatars Parent object. If you are not using scene lighting to influence your 3D avatars, or if you aren't using 3D avatars, you may opt to choose a location that is very far away from the scene.

You can optionallly set the Background Color and other values in the `PortraitsAvatar` component.

## 3. Bring in the Portraits UI

Bring the **Portraits UI** object, located in the `Prefabs` folder, into your scene as a child of your `Canvas`.

This is where your UI portraits will appear. The object is preset with UI components, though you may need to customize it to fit your project.

With **Portraits UI** selected in your Hierarchy, you'll see the `PortraitsPanel` component in the Inspector.

Populate the **UI Portrait** prefab with the prefab you will be using. By default, the UI Portrait prefab is selected. For now, you may wish to ensure everything instantiates properly before creating your own custom UI Portrait object.

## 4. Test it!

Bring hte "Demo Buttons" prefab into your scene as a child of the Canvas. These are the buttons used in the Demo Scene, and they will allow you to test the set up, and confirm everything is working correctly.

Press play, and click the "Load Portrait" button in the top left. Your portrait should load!

Once that is working, you can create your own [**Portrait Avatar**](/magic-pig-games/other/portrait-avatars/setup/create-a-portrait-avatar.md) and [**UI Portrait**](/magic-pig-games/other/portrait-avatars/setup/create-a-ui-portrait.md), customized to fit your game, with your art work, and your unique logic.

{% content-ref url="/pages/uy9efunjVxBpfJDH8Kba" %}
[Create a Portrait Avatar](/magic-pig-games/other/portrait-avatars/setup/create-a-portrait-avatar.md)
{% endcontent-ref %}

{% content-ref url="/pages/5oqjUh6QrqzFbiIbAody" %}
[Create a UI Portrait](/magic-pig-games/other/portrait-avatars/setup/create-a-ui-portrait.md)
{% endcontent-ref %}


---

# 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://infinitypbr.gitbook.io/magic-pig-games/other/portrait-avatars/setup.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.
