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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Bug Problem with building the asset bundle with scene

Discussion in 'Asset Bundles' started by RhAnjiE, Jan 27, 2023.

  1. RhAnjiE

    RhAnjiE

    Joined:
    Dec 7, 2016
    Posts:
    2
    After updating my project to 2022.2.1f1 I found a very problematic bug that won't let me to build asset bundles that containing scene. I got a message after 50 seconds:

    Build Task CalculateSceneDependencyData failed with exception:
    Object reference not set to an instance of an object


    The problem occurs in my code here:

    Code (CSharp):
    1. private ReturnCode BuildBundles(IBundleBuildContent buildContent, IBundleBuildParameters buildParameters)
    2. {
    3.    var taskList = Bundles.Tasks.Build.CalculateAndBuildBundles(); //<----------- here
    4.    var code = ContentPipeline.BuildAssetBundles(buildParameters, buildContent, out var results, taskList);
    5.  
    6.    return returnCode;
    7. }
    Code (CSharp):
    1. public static IList<IBuildTask> CalculateAndBuildBundles()
    2. {
    3.    var buildTasks = CalculateCommonBundles(); //<----------- here
    4.  
    5.    // Dependency
    6.    buildTasks.Add(new StripUnusedSpriteSources());
    7.    buildTasks.Add(new PostDependencyCallback());
    8.  
    9.    // Packing
    10.    buildTasks.Add(new GenerateBundlePacking());
    11.    buildTasks.Add(new GenerateBundleCommands());
    12.    buildTasks.Add(new GenerateSubAssetPathMaps());
    13.    buildTasks.Add(new GenerateBundleMaps());
    14.    buildTasks.Add(new PostPackingCallback());
    15.  
    16.    // Writing
    17.    buildTasks.Add(new WriteSerializedFiles());
    18.    buildTasks.Add(new ArchiveAndCompressBundles());
    19.  
    20.    buildTasks.Add(new CalculateDiffSignatures());
    21.    buildTasks.Add(new WriteResimoManifest());
    22.    buildTasks.Add(new PostWritingCallback());
    23.    return buildTasks;
    24. }
    Code (CSharp):
    1. public static IList<IBuildTask> CalculateCommonBundles()
    2. {
    3.    var buildTasks = new List<IBuildTask>();
    4.  
    5.    // Setup
    6.    buildTasks.Add(new SwitchToBuildPlatform());
    7.    buildTasks.Add(new RebuildSpriteAtlasCache());
    8.  
    9.    buildTasks.Add(new BuildPlayerScripts());
    10.    buildTasks.Add(new PostScriptsCallback());
    11.  
    12.    //Remove duplicated textures
    13.    buildTasks.Add(new CalculateScenesDuplicatedDependencies());
    14.    buildTasks.Add(new StripTextures());
    15.    buildTasks.Add(new RefreshAssetDatabase());
    16.  
    17.    buildTasks.Add(new CalculateSceneDependencyData()); //<----------- here
    18.    buildTasks.Add(new CalculateAssetDependencyData());
    19.  
    20.    return buildTasks;
    21. }

    When I test remove calling the CalculateSceneDependencyData(), I got the exception in ContentPipeline.BuildAssetBundles:

    Build Task GenerateBundlePacking failed with exception:
    The given key '94658ac7db67db047947acd7a55d4bac' was not present in the dictionary.


    I tried another versions of unity like 2022.2.3f1, 2022.2.2f1, 2022.2.0b16, 2022.2.0b10 and even 2023.1.0a18 but the problem also exists. The last working version is 2022.1.24f1.

    I removed any other asset bundles and left only this one with scene. I made sure that no dependencies are in several bundles. I also tried to build empty scene. Nothing helped. Only if I back to previous version (2022.1.24f1) the problem will disappear...

    Has anyone encountered this problem?
     
  2. RhAnjiE

    RhAnjiE

    Joined:
    Dec 7, 2016
    Posts:
    2