Class LegionDye

Namespace
PixelUnitStudio
Assembly
PixelUnitStudio.Runtime.dll

Dyes one part renderer. Redraws the art's main color group (the catalog option's dyeRamp, from dark colors) in the dye's color steps. The hero's skin color (Skins) likewise redraws the 3 base body skin colors. Shaders/LegionDye.shader does the color change; this component supplies the color pairs to change through a MaterialPropertyBlock. It stays in saved prefabs, so they are repainted the same way.

public sealed class LegionDye : MonoBehaviour
Inheritance
LegionDye

Constructors

LegionDye()

public LegionDye()

Fields

MaxColors

public const int MaxColors = 8

Field Value

int

MaxPairs

Number of color pairs the shader receives: part main colors MaxColors + skin SkinRamp.

public const int MaxPairs = 12

Field Value

int

Palettes

Available dyes. Names are kept in save records, so do not rename them. Colors are matched to the same tone as the parts (tone in tools/generate_humanoid_rig.py: saturation 78%, slightly warmer).

public static readonly IReadOnlyList<LegionDye.Palette> Palettes

Field Value

IReadOnlyList<LegionDye.Palette>

SkinRamp

The 3 skin colors of the base body (from dark). They appear in both the body and part art (tools/extract_base_style.py).

public static readonly Color32[] SkinRamp

Field Value

Color32[]

Skins

Available skin colors. shades has 3 steps like SkinRamp, and the name is kept in save records.

public static readonly IReadOnlyList<LegionDye.Palette> Skins

Field Value

IReadOnlyList<LegionDye.Palette>

from

public Color32[] from

Field Value

Color32[]

skin

public Color32[] skin

Field Value

Color32[]

to

public Color32[] to

Field Value

Color32[]

Methods

Apply()

public void Apply()

Custom(string)

A 5-step dye with the "#RRGGBB" color as the middle (step 3). The dark side gets a bit more saturation and the light side less, giving the same light-dark range as the base dyes. Null if the format is wrong. The name is normalized to uppercase "#RRGGBB".

public static LegionDye.Palette Custom(string hex)

Parameters

hex string

Returns

LegionDye.Palette

Find(string)

Finds a dye by name. For "#RRGGBB" it builds a dye with that color as the middle step (Custom). Null if none.

public static LegionDye.Palette Find(string name)

Parameters

name string

Returns

LegionDye.Palette

FindSkin(string)

public static LegionDye.Palette FindSkin(string name)

Parameters

name string

Returns

LegionDye.Palette

HexOf(Color)

Uses a color as a Custom dye name ("#RRGGBB").

public static string HexOf(Color color)

Parameters

color Color

Returns

string

Icon(Sprite, Color32[], Palette)

Dyed copy of a card icon. UI images don't use the dye shader, so pixels are changed directly. Returns the original icon if there is no dye, no main color group, or the icon is unreadable. The same icon and dye are made only once.

public static Sprite Icon(Sprite icon, Color32[] ramp, LegionDye.Palette palette)

Parameters

icon Sprite
ramp Color32[]
palette LegionDye.Palette

Returns

Sprite

Map(Color32[], Palette)

Matches the main color group to the dye steps. Centered on the middle (step 3): up to 5 colors map one per step; more are split evenly and paired.

public static Color32[] Map(Color32[] ramp, LegionDye.Palette palette)

Parameters

ramp Color32[]
palette LegionDye.Palette

Returns

Color32[]

Set(GameObject, Color32[], Palette, Palette)

Dyes the target renderer. No dye or no main color group gives the original color; no skin restores the default skin.

public static void Set(GameObject target, Color32[] ramp, LegionDye.Palette palette, LegionDye.Palette skin = null)

Parameters

target GameObject
ramp Color32[]
palette LegionDye.Palette
skin LegionDye.Palette