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:
- State Reversion: Calls
SetColor(_startingColor)to restore the initial color captured during theOpenPicker()call. - Tactile Feedback: Triggers a
SoftestBumphaptic to provide non-intrusive physical confirmation to the user. - Delayed Shutdown: Initiates the
DelayedClose()coroutine, allowing a brief buffer (default0.2s) for UI button animations to complete before deactivating the panel.
- State Reversion: Calls
- 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.