GameDevTecnico / cubos

A still very barebones game engine focused on voxels and data-oriented programming
https://gamedevtecnico.github.io/cubos/
MIT License
83 stars 23 forks source link

Handle NullableTrait in JSON Serializer/Deserializer #1162

Closed RiscadoA closed 1 month ago

RiscadoA commented 4 months ago

Problem

Currently the NullableTrait isn't handled, and thus both serializer and deserializer fail for Opt<T> types. One example is the RenderTargetDefaults component from the renderDefaultsPlugin. It contains the optional fields bloom and splitScreen. It should be possible to just add "bloom": null to the scene file to disable the optional.

Solution

When a type with NullableTrait is found, it should be checked. If it is null, null should be serialized. On deserialization, if null is found, then the type should be set to null.