Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

Help Wanted SBP. Help find option to build MonoScripts into their own bundle

Discussion in 'Asset Bundles' started by Jes28, Jun 23, 2021.

  1. Jes28

    Jes28

    Joined:
    Sep 3, 2012
    Posts:
    785
    from v1.18 changelog:
    Added an option to build MonoScripts into their own bundle reducing duplication and potential loading errors on certain project setups

    Can not find this option not in docs nor in actual api :(
    Do someone knows where it is?
     
  2. Jes28

    Jes28

    Joined:
    Sep 3, 2012
    Posts:
    785
    bump
     
  3. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,505
    Sounds interesting, can we find any documentation to what this is? @ryanc-unity
     
  4. OndrejP

    OndrejP

    Joined:
    Jul 19, 2017
    Posts:
    168
    It's there:
    DefaultBuildTasks.Create(DefaultBuildTasks.Preset.AssetBundleShaderAndScriptExtraction);

    Code (CSharp):
    1. static void BuildAssetBundles(string outputPath, BuildOptions buildOptions, BuildAssetBundleOptions bundleOptions, BuildTarget targetPlatform, AssetBundleBuild[] bundles)
    2. {
    3.     var group = BuildPipeline.GetBuildTargetGroup(targetPlatform);
    4.     var parameters = new BundleBuildParameters(targetPlatform, group, outputPath);
    5.     if ((options & BuildAssetBundleOptions.ForceRebuildAssetBundle) != 0)
    6.         parameters.UseCache = false;
    7.  
    8.     if ((options & BuildAssetBundleOptions.AppendHashToAssetBundleName) != 0)
    9.         parameters.AppendHash = true;
    10.  
    11.     if ((options & BuildAssetBundleOptions.ChunkBasedCompression) != 0)
    12.         parameters.BundleCompression = BuildCompression.LZ4;
    13.     else if ((options & BuildAssetBundleOptions.UncompressedAssetBundle) != 0)
    14.         parameters.BundleCompression = BuildCompression.Uncompressed;
    15.     else
    16.         parameters.BundleCompression = BuildCompression.LZMA;
    17.  
    18.     if ((options & BuildAssetBundleOptions.DisableWriteTypeTree) != 0)
    19.         parameters.ContentBuildFlags |= ContentBuildFlags.DisableWriteTypeTree;
    20.  
    21.    var content = new BundleBuildContent(bundles);
    22.    var taskList = DefaultBuildTasks.Create(DefaultBuildTasks.Preset.AssetBundleShaderAndScriptExtraction);
    23.    ReturnCode exitCode = ContentPipeline.BuildAssetBundles(parameters, content, out IBundleBuildResults results, taskList);
    24.  
    25.    var manifest = ScriptableObject.CreateInstance<CompatibilityAssetBundleManifest>();
    26.    manifest.SetResults(results.BundleInfos);
    27.    File.WriteAllText(parameters.GetOutputFilePathForIdentifier(Path.GetFileName(outputPath) + ".manifest"), manifest.ToString());
    28. }
     
    Last edited: Aug 1, 2021
    Jes28 likes this.
  5. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    318
    Ya, that was dumb of me, I spent time ensuring the options were properly exposed and documented in Addressables but overlooked SBP's own docs / options. Logged a task to update the SBP docs for this.
     
    Jes28 likes this.
unityunity