Question by
kala476 · Feb 07, 2020 at 12:43 AM ·
serializationmaccustom-inspectoreditorguilayoutserializedproperty
serializedObject.FindProperty working on Windows, not working on Mac.
So. I have a Script that extends the Button class, so that I can change the text colour of children components while the sprite swap happens. I also wrote a custom inspector so I can set the target colours from there. It works wonders on my Windows PC but I have just pushed on my Mac and it throws me NullReferenceExceptions there: The properties of type "Color" are not being found .
I already researched it and figured that this happens it's because the type Color is nor serializable and Find Property does not work with non-serializable classes. What I don't understand is why it works on windows in the first place, and how can I make it work on mac.
Relevant code snippets.
public class ExtendedButton : Button
{
[Header("Extensions")]
public bool changeChildTextColor;
[Header("Child Text Colors")]
[SerializeField] private Color extensionNormalColor = Color.white;
[SerializeField] private Color extensionHighlightedColor = Color.white;
....
[CustomEditor(typeof(ExtendedButton))]
public class ExtendedButtonEditor : ButtonEditor
{
SerializedProperty extensionNormalColorProperty;
SerializedProperty extensionHighlightedColorProperty;
private bool changeChildTextColour;
protected override void OnEnable()
{
base.OnEnable();
changeChildTextColour_property = serializedObject.FindProperty("changeChildTextColor");
extensionNormalColorProperty = serializedObject.FindProperty("extensionNormalColor");
extensionHighlightedColorProperty = serializedObject.FindProperty("extensionHighlightedColor");
}
Many Thanks
Comment