A simple color picker tool for Unity.
- Use the Package Manager:
Window > Package Manager > Install package from git URL...
https://github.com/scaredcrowgames/colorpicker.git?path=src
- Or add this to your Unity project's
Packages/manifest.json
:
"com.scaredcrowgames.colorpicker": "https://github.com/scaredcrowgames/colorpicker.git?path=src"
- Get it from Unity Asset Store
Access from the top menu: Tools > ColorPickerGenerator
Features:
- Add, remove, reorder colors
- Import colors from image
- Save/load color presets as .json files
- Configure texture size and column layout
- Save and auto-setup generated texture in .png format
Tip
Strongly recommend to use ready-to-use prefab from Samples (skip this section if so).
- Generate (see above) or import your color palette texture
- Create UI image and assign the texture
- Create child image (raycast target should be disabled, rect middle-center, size is no matter)
- Assign outline texture to child image
- Attach ColorPicker component to any object and assign palette image and outline rect in Inspector.
The package includes:
📁 Samples/ contains ColorPickerDemo.unity, palette and outline images, preset example and ready-to-use prefab
Import it from Package Manager > Samples
The ColorPicker.cs (MonoBehaviour) allows to select colors from the palette at runtime. Subscribe to ColorSelectionChanged
colorPicker.ColorSelectionChanged += color => {
Debug.Log("Selected color: " + color);
};
Or get current selected color directly:
var currentSelectedColor = colorPicker.CurrentSelectedColor;
Note
Default color before the very first selection is white-transparent
Tip
All discussions, requests and bug reports can be left in the corresponding Discord channel or here in Discussions