6

I created a Serializable class for my inspector.

[Serializable]
public class CellType
{
    [SerializeField]
    public int? Cost; // This does not appear in the inspector

    [SerializeField]
    public Color MaterialColor;
}

The nullable field Cost does not appear in the inspector. I use this class by creating a SerializeField

[SerializeField]
private CellType[] types;

If the field Cost would be a default int the field would appear. Is a workaround possible?

Question3r
  • 2,166
  • 19
  • 100
  • 200
  • 9
    This should not have been marked as a duplicate. While it has the words "serializable" and "nullable" in it, the actual intent of the question is entirely different. It's about how to write a property drawer in unity that would render this data type. – Aaron Sarazan Oct 26 '18 at 16:38
  • 1
    This answer is better than the proposed one: https://stackoverflow.com/questions/52854129/unity-doesnt-serialize-int-field – NicklasF Oct 05 '19 at 20:45

0 Answers0