Detailed Method Reference

Namespace: Canley.Utility.ColourPicker
Class: CanleyColourPickerTheme

ApplyTheme

public void ApplyTheme()
  • Description: Forces an immediate update of all theme settings to the target UI components. While the script normally updates automatically in the Editor, this method is used to refresh visuals if theme values are changed programmatically at runtime.
  • Workflow:
    1. Heading Refresh: Updates all assigned TextMeshPro labels with selected fonts and colors.
    2. Input Refresh: Synchronizes point sizes and fonts across all numerical and hex input fields, including placeholders.
    3. Button Refresh: Rebuilds the ColorBlock for all primary and secondary buttons to match the theme’s normal, hover, and pressed states.
  • Returns: void
  • Example:
using UnityEngine;
using Canley.Utility.ColourPicker;
 
public class DynamicThemeSwitcher : MonoBehaviour 
{
    [SerializeField] private CanleyColourPickerTheme _theme;
 
    public void SetDarkMode() 
    {
        // ... Logic to change serialized color values on the theme script ...
        
        // Apply the changes to the UI immediately
        _theme.ApplyTheme();
    }
}

TIP

This method is safe to call at any time. If you find the UI isn’t visually updating after a runtime change to a theme property, calling ApplyTheme() will resolve the synchronization.