I am trying to set up something where the private backing field is a string, but the public property seen by Unity is a Color. I am doing this so that I can store more compact hexadecimal strings on disk, but still work with pickable colors in the editor.
However the properties in the Unity Inspector still act like strings.
[SerializeField]
[Candlelight.PropertyBackingField("Background")]
private string background;
public Color GetBackground()
{
Color c;
if (ColorUtility.TryParseHtmlString(this.background, out c))
{
return c;
}
else
{
this.background = ColorUtility.ToHtmlStringRGBA(new Color(0, 0, 0, 0));
return new Color(0, 0, 0, 0);
}
}
public void SetBackground(Color value)
{
this.background = ColorUtility.ToHtmlStringRGBA(value);
}