Search Unity

How to NOT include streaming assets in certain builds

Discussion in 'Editor & General Support' started by Jelmer123, Oct 7, 2019.

  1. Jelmer123

    Jelmer123

    Joined:
    Feb 11, 2019
    Posts:
    243
    When I build my app for any platform, Unity adds whatever is in the streamingassets folder, also when it has nothing to do with the target platform.
    So my Android app gets my WebGL and Standlone OSX assetbundles, making it 3x as large for no reason.

    Is there a way to tell Unity not to add asset bundles? :D
     
  2. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    There is no build in way but you might like to take a look at IPreprocessBuildWithReport

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

    It should allow you to move any file you do not like to include from your streamingassets folder on a per platform bases out of the streamingassets to a temporary location and use IPostprocessBuildWithReport to move the files back after the build.
    https://docs.unity3d.com/ScriptReference/Build.IPostprocessBuildWithReport.OnPostprocessBuild.html
     
    sntilt and Jelmer123 like this.
  3. Also depending on your circumstances, your deadlines, your willingness of exploration, you can take a look and play with the Scriptable Build Pipeline.
    https://docs.unity3d.com/Packages/com.unity.scriptablebuildpipeline@1.5/manual/index.html
     
    Jelmer123 likes this.