Getting Started
Installation
Make sure the following packages are present before you open the demo scene or drop the prefab into your own UI:
- Unity 2021.3 LTS or newer
- TextMeshPro (import TMP Essentials when prompted)
- Unity UI (
com.unity.ugui)
Basic Setup
Add the prefab to a Canvas
- Create or select a Canvas in your scene (
GameObject → UI → Canvas). - Drag
ColorPicker.prefabinto the Canvas hierarchy. Use the themed variant if you want the pre-styled look. - Position and scale the
ColorPickerManagerGameObject as needed with the RectTransform tools.
Connect the picker to your UI
You can wire listeners directly in the Inspector (UnityEvents on OnColorChanging / OnColorChanged) or subscribe from code. The layout below keeps a preview image in sync while the user drags and when they release.
using UnityEngine;
using UnityEngine.UI;
using XDPaint.ChromaPalette;
public class ColorPreview : MonoBehaviour
{
[SerializeField] private ColorPickerManager paletteManager;
[SerializeField] private Image previewImage;
void Awake()
{
// Start with a known color
paletteManager.SetColor(Color.white, notify: false);
// Live preview while the user drags
paletteManager.OnColorChanging.AddListener(color => previewImage.color = color);
// Apply or persist when the user releases
paletteManager.OnColorChanged.AddListener(color => previewImage.color = color);
}
}
Switching Modes
ColorPickerManager ships with seven layouts. Pick the one you want in the Inspector or swap it at runtime.
Inspector: Select the ColorPickerManager component and choose a value from Mode.
Script or Visual Scripting:
// Example: move between the rectangle picker and the texture sampler
paletteManager.SetMode(ChromaPaletteMode.Rectangle);
// Provide a texture before switching to Texture mode
paletteManager.SetPaletteTexture(myScreenshotTexture);
paletteManager.SetMode(ChromaPaletteMode.Texture);
Using Your Own Palettes
If you already have a ColorPalette asset, assign it to Palette Settings → Color Palette on the component, then switch to Palette mode. See the Color Palettes guide for authoring, generating, or scripting palette assets.
Next Steps
- Learn the complete UI surface and cursor controls in the Color Picker overview.
- Generate and refine palette assets with the Color Palettes guide.
- Browse advanced recipes (themes, persistence, accessibility) in API → Code Examples.
- Need usage details for every field and method? Check the ColorPickerManager API.