Detailed Event Reference

Namespace: Canley.Utility.ColourPicker
Class: CanleyColourController

OnColorFinalized

public static Action<Color> OnColorFinalized
  • Description: A static global event fired upon confirmation. This allows any script in your project to listen for a color selection without needing a direct reference to a specific Picker instance.

  • Workflow:

    1. Trigger: User clicks the ‘Confirm/Select’ button on any active Picker.
    2. Static Invocation: The event is broadcasted globally across the application.
    3. Cleanup: The picker UI closes, but the static event ensures the data reaches your global managers.
  • Parameters:

    • Color: The finalized color selected by the user.
  • Example:

// No reference to the picker instance required!
void OnEnable() 
{
    // Subscribe to the global static event
    CanleyColourController.OnColorFinalized += GlobalColorListener;
}
 
void OnDisable()
{
    // Always unsubscribe from static events to prevent memory leaks
    CanleyColourController.OnColorFinalized -= GlobalColorListener;
}
 
void GlobalColorListener(Color finalCol) 
{
    Debug.Log($"A color was picked globally: {finalCol}");
    // Apply to a global settings manager or persistent player data
}

IMPORTANT

Static Event Warning: Because this event is static, it will persist even if the object subscribing to it is destroyed. Always unsubscribe in OnDisable() or OnDestroy() to prevent “MissingReferenceExceptions” or memory leaks.