Search Unity

Disabling Prefab baking for build

Discussion in 'Scripting' started by joshcamas, Feb 11, 2019.

  1. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    701
    Hello friends!

    I'm wanting to implement modding into my game, and thus I wish to keep prefabs intact during a build.
    I plan on implementing my own baking process that happens in the player, that will depend on what mods do what.

    I understand that baking is very good for 99% of people, but I'm wondering if there is any way to disable it.

    Thanks!
    Josh
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    3,766
    If you mean light baking, you can turn that off in the lighting settings window for your scene.
     
  3. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    701
    Sorry, I mean during build time when nested prefabs are combined. IE during build time each nested prefab is baked into thicc assets, since there's no need in having them in a build, for most people.
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    3,766
    I don't have any experience with the new nested prefabs. I doubt they are handled any differently than the geometry-baking pipeline for other items, which obviously only happens if you check the static geometry field in the editor. If you don't want mesh combination, turn off that checkbox in the scenes/prefabs.

    If you just want to combine meshes for performance at runtime you can do this all day long with any of the mesh combination scripts out there.
     
  5. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    701
    Sorry, it isn't about mesh combinations either.

    During building, nested prefabs merge together. In other words:

    house.prefab:
    -door.prefab
    -candle.prefab
    -candle.prefab

    Would merge into a single prefab, combining the house,door,and the two candles into a single "asset":

    house.prefab

    And of course, if there are any references to candle.prefab, it would *also* have that as well. What this results in is more data, but also no streaming speed reduction even if you have extremely deep nests. (Since it's all combined during building). This makes perfect sense for most people, but not for me.
     
  6. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    3,873
    This was never an option in Unity. Prefabs always went to GameObjects during build. Hence you instantiate only GameObjects during run time. There is no way to keep Prefabs around run time at the moment and AFAIK there are no plans to change that.

    Your best bets are the Addressables and the Asset Bundles if you're thinking about modding.
     
  7. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    701
    Okii dokii :) thank you