Detailed Method Reference

Namespace: Canley.Utility.ColourPicker
Class: CanleyMiniSwatch

Initialize

public void Initialize(Color col, CanleyColourController controller)
  • Description: The setup method called immediately after the swatch is spawned. It binds the swatch to a specific color and connects it to the central controller for communication.
  • Parameters:
    • col: The Unity Color this swatch will represent and store.
    • controller: A reference to the active CanleyColourController that this swatch will report to when clicked or deleted.
  • Workflow:
    1. Color Assignment: Sets the internal color and updates the Image component visuals.
    2. Linkage: Establishes the reference to the controller.
    3. Visual Validation: Checks if the color is transparent and toggles the alpha-checkerboard background if necessary.
  • Returns: void

TIP

If you are building a custom palette loader, ensure you call Initialize immediately after Instantiate to prevent NullReferenceExceptions when the user interacts with the swatch.