CanleyColourController
Namespace: Canley.Utility.ColourPicker
Base Class: MonoBehaviour
Overview
The CanleyColourController is the central nervous system of the Colour Picker suite. It handles state synchronization across sliders, hex inputs, and palettes, ensuring that the UI and your game materials stay perfectly in sync.
Event Reference
These events allow you to hook your game logic into the picker’s lifecycle.
| Event | Type | Description |
|---|---|---|
| OnLiveUpdate | Action<Color> | (Instance) Fires every time a slider moves or a color is picked. Ideal for real-time material previews. |
| OnColourConfirmed | Action<Color, string, Color32> | (Instance) Fires when the ‘Confirm’ button is pressed. Provides the Color, Hex string, and Color32. |
| OnColorFinalized | Action<Color> | (Static) A global hook that fires whenever any picker in the scene confirms a selection. |
| OnPickerClosed | Action | (Instance) Fires when the picker UI is deactivated, whether via confirm, cancel, or manual close. |
Method Reference
Select a method name for detailed parameters and code examples.
| Class | Method (Syntax) | Description |
|---|---|---|
| CanleyColourController | OpenPicker() | Activates the UI and captures the current color for potential cancellation/reversion. |
| CanleyColourController | ClosePicker() | Deactivates the UI panel immediately. |
| CanleyColourController | SetColor(Color newCol) | Programmatically updates the picker state (with a smooth lerp transition). |
| CanleyColourController | ConfirmSelection() | Finalizes the choice, triggers confirmation events, and closes the UI. |
| CanleyColourController | CancelSelection() | Reverts the color to the “Starting Color” captured during OpenPicker() and closes. |
| CanleyColourController | AddCurrentColorToPalette() | Persists the current color to the user’s saved swatch library. |
Key Properties
Accessible via Inspector or Code:
GlobalHapticsEnabled(static bool): A master switch to silence haptics across all pickers (e.g., for a global settings menu).GetCurrentColor()(Color): A helper method to retrieve the current active color from the preview swatch.Use Alpha(bool): When disabled in the Inspector, the UI automatically hides transparency controls and forces Alpha to 255.
NOTE
Assembly Definitions: If your project uses
.asmdeffiles, ensure you addCanley.Utility.ColourPickerandCanley.Utility.Runtimeto your references to avoid compilation errors.