Detailed Event Reference

Namespace: Canley.Utility.ColourPicker
Class: CanleyColourController

OnColourConfirmed

public event Action<Color, string, Color32> OnColourConfirmed
  • Description: Fired when the user clicks the “Confirm” or “Select” button. It provides the final color in three different formats for convenience, making it the ideal hook for saving selections to a database or player profile.

  • Workflow:

    1. Trigger: User clicks the “Confirm/Select” button in the UI.
    2. Format Conversion: The controller automatically converts the active color into Hex and Color32 formats.
    3. Invocation: The event fires, passing all three formats to subscribers.
    4. Shutdown: The picker initiates its ClosePicker sequence immediately after.
  • Parameters:

    • Color: The final color as a standard float RGBA (0.0 to 1.0).
    • string: The color formatted as a Hexadecimal string (e.g., "#FF0000FF").
    • Color32: The color in byte format (0 to 255).
  • Example:

void OnEnable() 
{
    // Subscribe to the confirmation event
    picker.OnColourConfirmed += SaveSelectionToProfile;
}
 
void OnDisable()
{
    // Unsubscribe to prevent memory leaks
    picker.OnColourConfirmed -= SaveSelectionToProfile;
}
 
void SaveSelectionToProfile(Color c, string hex, Color32 c32) 
{
    Debug.Log($"User confirmed {hex}. Saving to database...");
    
    // Example: Save the Hex string to PlayerPrefs
    PlayerPrefs.SetString("UserCustomColor", hex);
}

TIP

Use the Hex string for saving to JSON or Databases, and the Color32 if you are working with low-level procedural mesh textures to save on memory.