# 2. Colorblind-Safe Palettes
Part of [[Accessibility]]. Prev: [[1. Accessibility Mindset and the Module]]. Next: [[3. Subtitle Scale and Captions]].
## 2.1 Official palette API
`UnityEngine.Accessibility.VisionUtility.GetColorBlindSafePalette` (6000.5):
```csharp
public static int GetColorBlindSafePalette(Color[] palette, float minimumLuminance, float maximumLuminance);
```
You **allocate** `palette` to the size you need. The return value is the number of **unambiguous** colors; if that is smaller than `palette.Length`, the array **repeats** colors in order. Luminance is 0-1. Docs: use **0.2 or greater** as a minimum on dark backgrounds, **0.8 or less** as a maximum on light backgrounds. The set is intended to be distinguishable for normal vision, deuteranopia, protanopia, and tritanopia.
```csharp
using UnityEngine;
using UnityEngine.Accessibility;
/// <summary>Fills a team/item palette. NOT compiled in Unity.</summary>
public static class SafePalette
{
public static Color[] Make(int count, float minLum = 0.2f, float maxLum = 0.8f)
{
var palette = new Color[Mathf.Max(1, count)];
int unique = VisionUtility.GetColorBlindSafePalette(palette, minLum, maxLum);
if (unique == 0)
Debug.LogWarning("No unique colors for this luminance range.");
else if (unique < palette.Length)
Debug.LogWarning(
quot;Only {unique} unambiguous colors; extras repeat.");
return palette;
}
}
```
The official Scripting API also has an Editor swatch window example (IMGUI `OnGUI`) under **Window > Color Swatch Example** if you add their sample script. For a class tool, prefer a UI Toolkit window from [[Editor Windows with UI Toolkit]] that calls the same API - do not require IMGUI.
Use this for **debug gizmos, charts, team tints, item rarity**. Always also attach an **icon or pattern** (the official swatch sample itself uses background patterns when colors repeat - that instinct belongs in the game too).
## 2.2 A Volume grade is not a palette
A player-facing "colorblind filter" via [[Post-Processing]] Color Adjustments / Color Lookup can be an *extra*. It does not replace distinguishable HUD design, and there is no official 6000.5 "deuteranopia Volume" this series will invent.
## 2.3 Exercise
Generate an 8-color palette at (0.2, 0.8) and print `unique`. Assign colors to four teams and add a unique icon per team. If you squint or view a screenshot in grayscale, you should still tell them apart.
## Sources
- `GetColorBlindSafePalette` (6000.5): https://docs.unity3d.com/6000.5/Documentation/ScriptReference/Accessibility.VisionUtility.GetColorBlindSafePalette.html