Scripting

v1.0

The demo scene has a demo game controller, which calls many of these methods, if you'd like to see them in action.

Setting Values

Set the UI Color

The UI Color is set on the Portrait UI component for all portraits. Each of these will call the similar method on the portraitUI class.

β†’ There is an optional bool instant argument, default false. When true, the color will be set instantly, otherwise it will be transitioned to, based on the transition values in the Portrait UI.

β†’ There is also an optional bool onlySetFirstItem argument, also default false. When this is true, only the first Image in the list of border UI elements will be set.

β†’ You can also pass in a specific index to set the value for only one in game portrait.

// Set the border color for all avatars
PortraitAvatars.instance.SetBorderColor(colorValue);

// Instantly set the border color for a specific avatar, including all UI elements
// onlySetFirstItem is false
// instant is true
PortraitAvatars.instance.SetBorderColor(colorValue, inGameAvatarIndex, false, true);

Set Background Color (3D Avatars)

The Background Color is set on the Avatar Camera for 3D avatars. Each of these will ultimately call the similar method on the avatarCamera component attached to the Portrait3D class on your in game portrait.

β†’ There is an optional bool instant argument, default false. When true, the color will be set instantly, otherwise it will be transitioned to, based on the transition values in the Avatar Camera.

β†’ You can also pass in a specific index to set the value for only one in game portrait.

Set Light Color (3D Avatars)

The Light color is set on the Portrait 3D for 3D avatars. Each of these will ultimately call the similar method on the portrait3D component.

β†’ There is an optional bool instant argument, default false. When true, the color will be set instantly, otherwise it will be transitioned to, based on the transition values in the portrait3D.

β†’ There is also an optional bool onlySetFirstItem argument, also default false. When this is true, only the first Light in the list of lights will be set.

β†’ You can also pass in a specific index to set the value for only one in game portrait.

Set Light Intensity (3D Avatars)

The Light intensity is set on the Portrait 3D for 3D avatars. Each of these will ultimately call the similar method on the portrait3D component.

β†’ There is an optional bool instant argument, default false. When true, the color will be set instantly, otherwise it will be transitioned to, based on the transition values in the portrait3D.

β†’ There is also an optional bool onlySetFirstItem argument, also default false. When this is true, only the first Light in the list of lights will be set.

β†’ You can also pass in a specific index to set the value for only one in game portrait.

Caching Values

When a new portrait is created, it will use the cached color values when the "cache" toggles are true in the Inspector. These methods are called whenever you Set a value, but you can also call them directly outside of the Set methods.

Last updated

Was this helpful?