Portrait Avatars

v1.0

This is the "brain" of the system, and should generally be attached to an object that is a child of your "Player" character. There is a Portrait Avatars Parent prefab which you can bring into your scene.

If you plan on customizing this object, after you bring it into your scene rename it appropriately and save it as a new prefab. This way, when the package is updated, you won't accidentally overwrite your work.

The object with PortraitAvatars on it is the parent object for all 3D portrait avatars. If you are only using 2D portrait avatars, you still need this in your scene if you plan on updating the UI color at runtime.

If you are not going to modify any of the UI colors, or if you will be running your own system for that, then you do not need to bring this object into your scene.

Required for 3D Avatars

Portrait Avatar 3D Prefab

This is the "Avatar" object. This object should have a Portrait3D component on it.

There's a very good chance you'll want to create your own prefab based off of the Portrait Avatar prefab which comes in the package. Most likely you'll have additional logic to handle what exactly is shown in the portrait.

The 3D avatar is a model, but what is it wearing? What are the colors? What materials are assigned? In most games, you'll likely not be showing the exact same character.

In the demo, we use the Portrait Avatar - Demo 3D prefab. Check that out to see the DemoAvatarLoader script which is used whenever a 3D avatar is instantiated into the game.

pageCreate a Portrait Avatar

Available Layers (3D)

Each 3D portrait must be on its own, unique layer. Select the portrait layers you've created in this field.

The number of layers selected here determines the total number of 3D portraits you can have in your project at any one time.

However, if you're using 2D portraits that do not have their own camera, then they do not need to be on their own layer, and

Local Spawn Position

This is the position, locally relative to the Portrait Avatars Parent, where 3D avatars are spawned. One trick to ensure that 3D avatars are receiving the real light at that position, while minimizing the chance that an object blocks the portrait cameras view of the object, is to make the avatar very small.

If you do that, you likely would want to set the Y position higher than 0. In the demo scene, we use 1.2f for this value.

Colors

The PortraitAvatars script can set the colors on your portraits for you.

The Image / RawImage Color is the 2D image or the 3D RawImage which displays the output of the avatar camera. The UI Color is the UI elements that your UI Portrait prefab has set on the PortraitUI component. Finally, the Background Color is the background of the 3D avatar portraits, set on the Avatar Camera.

You can set each of these colors to default values, and they can also be updated at runtime. When updated, each portrait in the scene will receive the update.

Caching Values

By default, the script will cache the value any time you update the colors. This way, when a new portrait is instantiated, the colors will be instantly set to the last used colors.

Only Set First UI Image

False by default, when true, any update to the color will only affect the first UI image in the list of UI images on the Portrait UI component. Also, when scripting changes, you're able to specify whether you'd like to include only the first UI image or not.

Lights (3D Avatars)

The PortraitAvatars script can also set the lighting on your 3D avatars. This has no impact on 2D avatars.

The system will cache any light color or intensity changes, so that any new 3D avatars instantiated will start with the same settings as any other portraits already active.

You can optionally only control the first Light in the list of lights on the Portrait3D component.

pageScripting

Last updated