Create palettes of colors and components for change specific color on a specific visual element. Very useful to UI.
Create palettes of colors and components to change specific colors on a specific visual element. Very useful for UI.
Image
, SpriteRenderer
, TextMeshPro
, etcopenupm add extensions.unity.theme
Window/Unity-Theme
ColorBinder
components to a target GameObjectA component that binds a color to a specific target, such as Image
, SpriteRenderer
, TextMeshPro
, or anything else.
There is a list of built-in color binders:
ImageColorBinder
SpriteRendererColorBinder
TextMeshProColorBinder
Modify palettes, instant response with all connected GameObjects.
using Unity.Theme;
Theme.Instance.AddColor("Primary", "#6750A4");
Theme.Instance.AddColor("Primary", Color.white);
Theme.Instance.SetColor("Primary", "#6750A4");
Theme.Instance.SetColor("Primary", Color.white);
Theme.Instance.SetOrAddColor("Primary", "#6750A4");
Theme.Instance.SetOrAddColor("Primary", Color.white);
Theme.Instance.RemoveColorByName("Primary");
Theme.Instance.RemoveColor(colorData);
Theme.Instance.RemoveAllColors();
using Unity.Theme;
Theme.Instance.AddTheme("Light");
Theme.Instance.SetOrAddTheme("Light");
Theme.Instance.CurrentThemeName = "Light";
Theme.Instance.CurrentThemeIndex = 0;
Theme.Instance.RemoveTheme("Light");
Theme.Instance.RemoveAllThemes();
ColorBinder
If you need to bind color to something else, you may extend from BaseColorBinder
as listed below.
using UnityEngine;
using TMPro;
namespace Unity.Theme.Binders
{
[AddComponentMenu("Theme/TextMeshPro Color Binder")]
public class TextMeshProColorBinder : BaseColorBinder
{
[SerializeField] TextMeshProUGUI textMeshPro;
protected override void Awake()
{
if (textMeshPro == null) textMeshPro = GetComponent<TextMeshProUGUI>();
base.Awake();
}
protected override void SetColor(Color color)
{
textMeshPro.color = color;
}
}
}