> For the complete documentation index, see [llms.txt](https://postica.gitbook.io/coloref/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://postica.gitbook.io/coloref/scripting/runtime-setup.md).

# Setting Up at Runtime

Set the active palette when your game starts, so linked fields work in a build.

Everything in ColoRef's scripting API lives in the `Postica.ColoRef` namespace, and most of it goes through one static class: `PaletteManager`.

## The one line your build needs

In the editor, the Palette Manager remembers which palette is active. That's an editor preference, so a build starts with no active palette. Set it when the game starts:

```csharp
using Postica.ColoRef;
using UnityEngine;

public class PaletteSetup : MonoBehaviour
{
    [SerializeField] ColoRefAsset palette;

    void Awake()
    {
        PaletteManager.Active = palette;
    }
}
```

Add it to an object in your first scene and assign the palette in the Inspector. The serialized field matters: it's also what makes Unity include the palette asset in the build.

{% hint style="success" %}
If you offer palette options to players, the **Palette Player Settings** component can make its palette active for you, and remembers the player's theme too. See [Player Settings](/coloref/using-coloref/player-settings.md).
{% endhint %}

Order doesn't matter. Objects that are already loaded update as soon as `Active` is set, and objects loaded later pick up the values on their own.

## Remembering the player's theme

Set the variation in the same place:

```csharp
void Awake()
{
    PaletteManager.Active = palette;
    PaletteManager.ActiveVariation = PlayerPrefs.GetString("theme", "Default");
}

public void SetTheme(string variation)
{
    PaletteManager.ActiveVariation = variation;
    PlayerPrefs.SetString("theme", variation);
}
```

## Loading the palette later

If the palette comes from Addressables, an AssetBundle or `Resources`, load it however you like and assign `Active` once it's loaded.

```csharp
var palette = Resources.Load<ColoRefAsset>("Palettes/Main");
PaletteManager.Active = palette;
```

## Swapping whole palettes

`Active` can change at any time, so a second palette is a good fit for things like a colour-blind mode. Create it with **Clone** in the Palette Manager: clones share entry ids with the original, so every link works with both.

```csharp
PaletteManager.Active = colorBlindMode ? colorBlindPalette : mainPalette;
```

## Next

* [Switching Themes](/coloref/scripting/switching-themes.md)
* [Reading Values in Code](/coloref/scripting/reading-values.md)
