Search Unity

Serializing editor entities in subscene

Discussion in 'Entity Component System' started by Scorr, Jan 4, 2021.

  1. Scorr

    Scorr

    Joined:
    Jul 2, 2013
    Posts:
    73
    I'm creating entities at edit-time and want to save them into a subscene.
    An example scenario is a map editor, with a map consisting of entities. Creating visible gameobject representations of all map entities would be a lot of redundancy, so it's easier to work with entities directly. Using entities also makes it trivial to use at runtime if need be.

    Currently I'm thinking of using SerializeUtility to store the entities in an authoring object and deserialize them at subscene conversion time.

    Serializing them is straightforward, but it feels weird to serialize them, deserialize them for subscene conversion, then have Unity serialize them again into the subscene. I guess the ideal scenario would be to serialize them directly into subscene format, and just add them to the subscene directly without extra deserialize/serialize steps. Is this currently possible/planned to be possible?

    Also, if anyone has better ideas on how to approach this I'd love to hear it.