📡 Event Reference
Namespace: Canley.Utility.ColourPicker
Class: CanleyColourController
Overview
The CanleyColourController uses C# Actions to allow external scripts to “hook into” the picker’s lifecycle. This decoupling ensures your project logic remains clean—allowing you to trigger sounds, update materials, or save data without ever modifying the core picker scripts.
Public Events
Click an event name for detailed information, parameter types, and code examples.
| Event | Type | Description |
|---|---|---|
| OnLiveUpdate | Action<Color> | (Instance) Fires every frame the color changes. Best for real-time visual updates. |
| OnColourConfirmed | Action<Color, string, Color32> | (Instance) Fires on “Confirm”. Provides the color in three formats for easy saving. |
| OnColorFinalized | Action<Color> | (Static) A global hook. Listen for any picker confirmation without needing a direct reference. |
| OnPickerClosed | Action | (Instance) Fires when the UI is hidden, regardless of whether the user confirmed or cancelled. |
Implementation Pattern
Most implementations follow this “Subscribe/Unsubscribe” pattern to ensure performance and stability:
void OnEnable()
{
// Subscribe when the object is active
picker.OnLiveUpdate += MyMethod;
}
void OnDisable()
{
// Unsubscribe when the object is disabled to prevent memory leaks
picker.OnLiveUpdate -= MyMethod;
}WARNING
Subscription Hygiene: Always unsubscribe from these events in
OnDisable()orOnDestroy(). This is especially critical for Static events likeOnColorFinalized, which can persist even after a scene change.