Serializing NGUI UIFont - "Material doesn't have a color property '_Color'"

I’m trying to serialize an NGUI UIFont using JsonFX:

UIFont uiFont = (Resources.Load("arial") as GameObject).GetComponent<UIFont>();
string serialized = JsonFx.Json.JsonWriter.Serialize(uiFont);

However, the second line throws two exceptions:

> Material doesn't have a color property
> '_Color'
> System.Reflection.MonoProperty:GetValue(Object,
> Object[])
> JsonFx.Json.JsonWriter:WriteObject(Object,
> Type)

And:

TargetParameterCountException: parameters do not match signature

I know that uiFont is not null (I checked), and this is pretty straightforward use of JxonFx. I’m not sure what would cause this error. Obviously it’s something that has to do with reflection, but uiFont.material.color is just a UnityEngine Color. I’m not sure why it’s looking for “_Color”.

What might cause this issue?

That’s simply because the Color property is not a variable. It’s a property and it’s setter will simply do a SetColor(“_Color”, value). So it’s just a shortcut. Most shaders have a _Color property, but there are a few that don’t have one or it’s called differently. Like the particle shaders. They have a property called _TintColor but no _Color, so reading or writing the Color property of a shader that doesn’t have a _Color will result in an error