Detailed Method Reference

Namespace: Canley.Utility.ColourPicker
Class: CanleyColourController

CancelSelection

public void CancelSelection()
  • Description: Reverts the Colour Picker to the state it was in when OpenPicker() was first called. This is the standard logic intended for “Cancel” or “Back” buttons.
  • Workflow:
    1. State Reversion: Calls SetColor(_startingColor) to restore the initial color captured during the OpenPicker() call.
    2. Tactile Feedback: Triggers a SoftestBump haptic to provide non-intrusive physical confirmation to the user.
    3. Delayed Shutdown: Initiates the DelayedClose() coroutine, allowing a brief buffer (default 0.2s) for UI button animations to complete before deactivating the panel.
  • Returns: void
  • Example:
using UnityEngine;
using Canley.Utility.ColourPicker;
 
public class PickerInputHandler : MonoBehaviour 
{
    [SerializeField] private CanleyColourController _picker;
 
    void Update() 
    {
        // Example: Global 'Escape' key to cancel color editing
        if (Input.GetKeyDown(KeyCode.Escape) && _picker.gameObject.activeSelf) 
        {
            _picker.CancelSelection();
        }
    }
}

TIP

This method relies on the _startingColor variable assigned during OpenPicker(). To ensure a valid revert state exists, always open your picker using the OpenPicker() method rather than toggling the GameObject manually.