I'm looking to extend UIBoxComponent and HUDComponent, but I realized that they store all the config into a settings object, which is then manually serialized via ISerializationCallbackReceiver. Since I can't extend the nested Setting class, I had to add my custom fields as regular fields in my subclasses, and then create custom editors to display these fields in the inspector.

It doesn't look like there is anything bad happening, but I do wonder what is the motivation behind serializing everything to a single object, what could go wrong with my current approach, and whether there is a better way to subclass these classes.
  • Adding your custom things as regular fields is fine - the serialized approach is used for 2 reasons:

    1) Unity's serialization isn't going very deep, so components wouldn't be able to save the data from the complex data structure, e.g. the conditions.

    2) Data upgrades - there are often changes in data structures when features are changed or replaced by more detailed settings. My own serialization can keep track of that and upgrade data to keep your settings useable without breaking anything.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.