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.

EventTypeDescription
OnLiveUpdateAction<Color>(Instance) Fires every time a slider moves or a color is picked. Ideal for real-time material previews.
OnColourConfirmedAction<Color, string, Color32>(Instance) Fires when the ‘Confirm’ button is pressed. Provides the Color, Hex string, and Color32.
OnColorFinalizedAction<Color>(Static) A global hook that fires whenever any picker in the scene confirms a selection.
OnPickerClosedAction(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.

ClassMethod (Syntax)Description
CanleyColourControllerOpenPicker()Activates the UI and captures the current color for potential cancellation/reversion.
CanleyColourControllerClosePicker()Deactivates the UI panel immediately.
CanleyColourControllerSetColor(Color newCol)Programmatically updates the picker state (with a smooth lerp transition).
CanleyColourControllerConfirmSelection()Finalizes the choice, triggers confirmation events, and closes the UI.
CanleyColourControllerCancelSelection()Reverts the color to the “Starting Color” captured during OpenPicker() and closes.
CanleyColourControllerAddCurrentColorToPalette()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 .asmdef files, ensure you add Canley.Utility.ColourPicker and Canley.Utility.Runtime to your references to avoid compilation errors.

7 items under this folder.