Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question To Bake or Not To Bake

Discussion in 'Entity Component System' started by Arkaid, Jun 8, 2023.

  1. Arkaid

    Arkaid

    Joined:
    Apr 5, 2014
    Posts:
    4
    That is the question!

    I find that creating a subscene and making authoring scripts is cumbersome and breaks the layout of the scene I'm trying to make.

    Instead I've chosen to create a regular scene and simply add Entities and Components directly when needed.
    So when, say, a new object spawns in the scene, I manually create entities from the EntityManager and add the required components it may need.

    I feel like there is an inherent cost to doing this rather than baking, but I would love some feedback from someone that may know better.

    Is there a significant disadvantage to manually handling entities and components rather than baking them?
     
  2. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    825
    you are simply doing your "baking" at runtime via the entitymanager vs using bakers in edit time. the disadvantage is you pay the cost in delaying starting the game and baked subscenes allow for streaming entities in and out very quickly which wont be possible for in your case. the further you go with this, the more wheel reinventing you will be doing as you are ignoring the builtin baking systems and functionality that unity is spending significant time developing.
     
    Ryiah and Arkaid like this.
  3. Arkaid

    Arkaid

    Joined:
    Apr 5, 2014
    Posts:
    4
    Thanks for the insight!
    I'll put some more time into fiddling with baking, then!
     
  4. Dog_Like

    Dog_Like

    Joined:
    Nov 24, 2017
    Posts:
    25
    Baking is not flexible, it's best to have entity prefabs that can be loaded when needed, instead of throwing everything into the scene from the beginning.
     
  5. TheOtherMonarch

    TheOtherMonarch

    Joined:
    Jul 28, 2012
    Posts:
    791
    You can bake prefabs.
     
  6. Dog_Like

    Dog_Like

    Joined:
    Nov 24, 2017
    Posts:
    25
    Yes, bake them all at the very beginning.
     
  7. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,292
    You're loosing loading performance.
    But, as subscenes aren't the most stable thing in the world - you're winning iteration time.

    Other than doing authoring manually not really. There's a bit of overhead due to wrappers, but simulation speed wise should be identical. Systems such as new Transform system, rendering etc can also be used if you know what they need in order to run.

    For hybrid approach, check out EntitiesExt, might find there a bunch of ideas how to make runtime authoring as fast as possible without subscenes.