Search Unity

Question Use SBP to build default content?

Discussion in 'Asset Bundles' started by Windwalk_Rosco, Dec 28, 2020.

  1. Windwalk_Rosco

    Windwalk_Rosco

    Joined:
    Aug 10, 2020
    Posts:
    20
    Is it possible to use the SBP to build the "None" asset bundle?

    I would like to strip some components from prefabs/scenes during certain builds. I.e. on a headless server build remove the mesh renderer from scenes and prefabs. This is super easy to do with scenes using the
    PostProcessSceneAttribute, but prefabs not assigned an asset bundle get built into a default sharedassets bundle. Is there anyway to customize that part of the build process?

    Alternatively is there any downside to automatically assigning all assets to a default asset bundle and loading those at startup?
     
  2. nilsdr

    nilsdr

    Joined:
    Oct 24, 2017
    Posts:
    374
    I suppose you could use the assetdatabase to query all assets in your project, find the ones that have no bundle assigned to them, and then apply your own 'global' bundle name.

    There is a general preprocess hook that is executed before your build starts, if you want to do processing that would probably be your starting point. Again, query the assetdatabase for assets of the type you'd like to process, and apply your logic accordingly.

    https://docs.unity3d.com/ScriptReference/Build.IPreprocessBuildWithReport.html

    You could then revert their state in a Postprocess command:

    https://docs.unity3d.com/ScriptReference/Build.IPostprocessBuildWithReport.html
     
  3. Windwalk_Rosco

    Windwalk_Rosco

    Joined:
    Aug 10, 2020
    Posts:
    20
    Yeah that's a potential approach though seems like a huge amount of overhead for a large project. Really don't understand why there aren't pipeline calls for bundling the built-in content