Is it possible to add a custom Persistent Variable that can store a Color type and be configured in the editor? I’m wondering if it’s possible to achieve this without modifying the original package code. Currently, I’m using a StringVariable to store the hex code of the color, but this approach is not very convenient.
Yes we support custom variables.
https://docs.unity3d.com/Packages/com.unity.localization@1.5/manual/Smart/Persistent-Variables-Source.html#custom-persistent-variables
You should be able to do something like the MyVariable example but with a Color property.
E.G
[Serializable]
public class MyColorVariable : IVariable, IVariableValueChanged
{
[SerializeField]
Color m_Value;
public Color Value
{
get => m_Value;
set
{
if (m_Value == value)
return;
m_Value = value;
ValueChanged?.Invoke(this);
}
}
public event Action<IVariable> ValueChanged;
public object GetSourceValue(ISelectorInfo _) => Value;
}
1 Like
Great. You may want to use ColorUtility.ToHtmlStringRGB to do the hex, save a few lines of code ![]()
You will need to prepend the “#” on the front though, it doesn’t include one.

