Search Unity

Resolved Auto generate Baker authoring flow?

Discussion in 'DOTS Dev Blitz Day 2022 - Q&A' started by echu33, Dec 8, 2022.

  1. echu33

    echu33

    Joined:
    Oct 30, 2020
    Posts:
    62
    I like the Baker authoring concept in DOTS 1.0. It certainly make the conversion from gameobject to ECS component more easily.

    But I found I need to rewrite very similar baker code for each MonoBehaviour over and over again.

    Will there a plan for improve this part?. Like auto generate baker code from attributes?
    Not sure if its possible. Just curious.
     
  2. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,109
  3. msfredb7

    msfredb7

    Joined:
    Nov 1, 2012
    Posts:
    163
    If Unity were to support this (like they did with GenerateAuthoringComponent), I think they'd need to support a robust way to maintain the data if you decide to make your own baker later.

    On my project, it happened quite often that GenerateAuthoringComponent was used for quick programming. However, later, when the authoring needs inevitably diverged from the runtime needs, a custom authoring component would be created, GenerateAuthoringComponent would be removed and the data would be lost.

    That's why we decided internally to ban GenerateAuthoringComponent.
     
  4. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,109
    Good case
    because of thins I want to use IComponentData Directly without any authoring component

    if it will change from runtime data I just create new component for runtime data and write custom baker nothing will be lost
     
  5. topher_r

    topher_r

    Unity Technologies

    Joined:
    Jun 14, 2019
    Posts:
    36
    Actually the data you have on a GameObject and anything this GameObject is assigned to unless you take particular care to replicate the exact MonoBehaviour for authoring in the same file the [GenerateAuthoringComponent] is in, will be lost. It is very fragile, and this as well as many other reasons are why it's gone.

    We have a better alternative that makes it easier to scaffold into a full Authoring+Baker combo, which is outlined here https://forum.unity.com/threads/generateauthoringcomponent-in-1-0.1342727/#post-8488502

    As it happens, it seems you replied in that thread already, Jes28 :)
     
    Kmsxkuse likes this.