Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [2.1.5] - 2024-09-24
- Fixed issue where total size of all bundles changes when updating the same Addressable Groups build.
- Fixed issue where more than 2 Scriptable Objects are nested and Compatability Pipeline is used to build.
  • Loading branch information
Unity Technologies committed Sep 24, 2024
1 parent 8f24dab commit fc1b2d2
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 32 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ All notable changes to this package will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [2.1.4] - 2024-06-26
Fixed issue where total size of all bundles changes when updating the same Addressable Groups build.
## [2.1.5] - 2024-09-24
- Fixed issue where total size of all bundles changes when updating the same Addressable Groups build.
- Fixed issue where more than 2 Scriptable Objects are nested and Compatability Pipeline is used to build.

## [2.1.3] - 2024-04-09
- Fixed error where key was already in a dictionary and we try to add it again
Expand Down
5 changes: 5 additions & 0 deletions Editor/CompatibilityBuildPipeline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ internal static CompatibilityAssetBundleManifest BuildAssetBundles_Internal(stri
if ((options & BuildAssetBundleOptions.DisableWriteTypeTree) != 0)
parameters.ContentBuildFlags |= ContentBuildFlags.DisableWriteTypeTree;

#if BUILD_OPTIONS_RECURSE_DEPENDENCIES_2022_3 || BUILD_OPTIONS_RECURSE_DEPENDENCIES_2023_3 || UNITY_6000_0_OR_NEWER
if ((options & BuildAssetBundleOptions.RecurseDependencies) != 0)
parameters.NonRecursiveDependencies = false;
#endif

IBundleBuildResults results;
ReturnCode exitCode = ContentPipeline.BuildAssetBundles(parameters, content, out results);
if (exitCode < ReturnCode.Success)
Expand Down
16 changes: 14 additions & 2 deletions Editor/Unity.ScriptableBuildPipeline.Editor.asmdef
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "Unity.ScriptableBuildPipeline.Editor",
"rootNamespace": "",
"references": [
"Unity.ScriptableBuildPipeline",
"UnityEditor.CacheServer"
Expand Down Expand Up @@ -28,6 +29,17 @@
"name": "Unity",
"expression": "2019.4.19f1",
"define": "NONRECURSIVE_DEPENDENCY_DATA"
},
{
"name": "Unity",
"expression": "[2022.3.21f1,2023.1)",
"define": "BUILD_OPTIONS_RECURSE_DEPENDENCIES_2022_3"
},
{
"name": "Unity",
"expression": "2023.3.0b1",
"define": "BUILD_OPTIONS_RECURSE_DEPENDENCIES_2023_3"
}
]
}
],
"noEngineReferences": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void Cleanup()
AssetDatabase.DeleteAsset(k_TmpAssetPath);
}

static CompatibilityAssetBundleManifest BuildPrefabBundles()
static CompatibilityAssetBundleManifest BuildPrefabBundles(bool recurseDeps)
{
// Put each prefab into its own AssetBundle
var bundleDefinitions = new AssetBundleBuild[k_CntPrefabChain];
Expand All @@ -72,11 +72,26 @@ static CompatibilityAssetBundleManifest BuildPrefabBundles()

// Todo, confirm that the NonRecursive Mode is enabled, the test assumes that it is and i think that is the default but its not exposed in this API

var manifest = CompatibilityBuildPipeline.BuildAssetBundles(
k_BuildFolder,
bundleDefinitions,
BuildAssetBundleOptions.AppendHashToAssetBundleName,
EditorUserBuildSettings.activeBuildTarget);
var manifest = default(CompatibilityAssetBundleManifest);

#if BUILD_OPTIONS_RECURSE_DEPENDENCIES_2022_3 || BUILD_OPTIONS_RECURSE_DEPENDENCIES_2023_3 || UNITY_6000_0_OR_NEWER
if (recurseDeps)
{
manifest = CompatibilityBuildPipeline.BuildAssetBundles(
k_BuildFolder,
bundleDefinitions,
BuildAssetBundleOptions.AppendHashToAssetBundleName | BuildAssetBundleOptions.RecurseDependencies,
EditorUserBuildSettings.activeBuildTarget);
}
else
#endif
{
manifest = CompatibilityBuildPipeline.BuildAssetBundles(
k_BuildFolder,
bundleDefinitions,
BuildAssetBundleOptions.AppendHashToAssetBundleName,
EditorUserBuildSettings.activeBuildTarget);
}

Assert.IsNotNull(manifest);

Expand All @@ -87,7 +102,7 @@ static CompatibilityAssetBundleManifest BuildPrefabBundles()
[Test, Description("BPSBP-736")]
public void BundeHashChanges_WhenDirectDependencyChanges()
{
CompatibilityAssetBundleManifest manifest = BuildPrefabBundles();
CompatibilityAssetBundleManifest manifest = BuildPrefabBundles(false);

//var outputFiles = Directory.EnumerateFiles(k_BuildFolder, "*", SearchOption.TopDirectoryOnly);
//Debug.Log("Output of the build:\n\t" + string.Join("\n\t", outputFiles));
Expand All @@ -103,7 +118,7 @@ public void BundeHashChanges_WhenDirectDependencyChanges()
// Change bundle 3, e.g. remove its dependency on bundle 4
SetPrefabReferenceToNull(3);

CompatibilityAssetBundleManifest manifest2 = BuildPrefabBundles();
CompatibilityAssetBundleManifest manifest2 = BuildPrefabBundles(false);

var rebuildPaths = new string[k_CntPrefabChain];
for (int i = 0; i < k_CntPrefabChain; i++)
Expand All @@ -125,7 +140,7 @@ public void BundeHashChanges_WhenDirectDependencyChanges()
[Test, Description("BPSBP-736")]
public void BundleHashDoesNotChange_IfListOfReferencedBundlesDoesNotChange()
{
CompatibilityAssetBundleManifest manifest = BuildPrefabBundles();
CompatibilityAssetBundleManifest manifest = BuildPrefabBundles(false);

//var outputFiles = Directory.EnumerateFiles(k_BuildFolder, "*", SearchOption.TopDirectoryOnly);
//Debug.Log("Output of the build:\n\t" + string.Join("\n\t", outputFiles));
Expand All @@ -141,7 +156,7 @@ public void BundleHashDoesNotChange_IfListOfReferencedBundlesDoesNotChange()
// Change bundle 3, e.g. remove its dependency on bundle 4
AddToTransformValues(3);

CompatibilityAssetBundleManifest manifest2 = BuildPrefabBundles();
CompatibilityAssetBundleManifest manifest2 = BuildPrefabBundles(false);

var rebuildPaths = new string[k_CntPrefabChain];
for (int i = 0; i < k_CntPrefabChain; i++)
Expand Down Expand Up @@ -195,12 +210,12 @@ static void AddToTransformValues(int prefabIndex)
}
#endif

[Ignore("BPSBP-737 / ADDR-3262")]
#if BUILD_OPTIONS_RECURSE_DEPENDENCIES_2022_3 || BUILD_OPTIONS_RECURSE_DEPENDENCIES_2023_3 || UNITY_6000_0_OR_NEWER
[Test, Description("BPSBP-737 / ADDR-3262")]
public void MonoScriptsAreNotNullInChainedBundles()
{
// Note: Test could also do variations, with MonoScript bundle enabled, maybe also NonRecursive=false
CompatibilityAssetBundleManifest manifest = BuildPrefabBundles();
CompatibilityAssetBundleManifest manifest = BuildPrefabBundles(true);

string prefabBundleMatch = "*_*"; // Match bundle names like 0_f5b4234bbd5a5a599bd740802cc6f9cf and ignore other build output

Expand All @@ -209,11 +224,10 @@ public void MonoScriptsAreNotNullInChainedBundles()
var builtBundlePaths = Directory.EnumerateFiles(k_BuildFolder, prefabBundleMatch, SearchOption.TopDirectoryOnly).ToArray();
LoadBundlesAndCheckMonoScript(builtBundlePaths);
}
#endif

static void LoadBundlesAndCheckMonoScript(string[] bundleNames)
{
//Debug.Log("Loading " + string.Join("\n", bundleNames));

var bundleCount = bundleNames.Length;
var bundles = new AssetBundle[bundleCount];
for (int i = 0; i < bundleCount; i++)
Expand All @@ -225,19 +239,13 @@ static void LoadBundlesAndCheckMonoScript(string[] bundleNames)
{
for (int i = 0; i < bundleCount; i++)
{
if (bundles[i].name == "UnityMonoScripts.bundle")
continue;

var prefab = bundles[i].LoadAllAssets<GameObject>()[0];
var monoBehaviour = prefab.GetComponent<MonoBehaviourWithReference>();

//TEMPORARY Assert disabled until BPSBP-737 fixed
//Assert.IsNotNull(monoBehaviour, "Missing MonoScript or MonoBehaviourWithReference on " + bundleNames[i]);
//

if (monoBehaviour == null)
{
// Missing monoscript will result in the entire MonoBehaviour not being loaded
Debug.Log("Missing MonoScript or MonoBehaviourWithReference on " + bundleNames[i]);
continue;
}
Assert.IsNotNull(monoBehaviour, "Missing MonoScript or MonoBehaviourWithReference on " + bundleNames[i]);

var monoScript = MonoScript.FromMonoBehaviour(monoBehaviour);
Assert.IsNotNull(monoScript);
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.unity.scriptablebuildpipeline",
"displayName": "Scriptable Build Pipeline",
"version": "2.1.4",
"version": "2.1.5",
"unity": "2019.4",
"description": "The Scriptable Build Pipeline moves the asset bundle build pipeline to C#. Use the pre-defined build flows, or create your own using the divided up APIs. This system improves build time, fixes incremental build, and provides greater flexibility.",
"keywords": [
Expand All @@ -14,15 +14,15 @@
],
"dependencies": {},
"_upm": {
"changelog": "Fixed issue where total size of all bundles changes when updating the same Addressable Groups build."
"changelog": "- Fixed issue where total size of all bundles changes when updating the same Addressable Groups build.\n- Fixed issue where more than 2 Scriptable Objects are nested and Compatability Pipeline is used to build."
},
"upmCi": {
"footprint": "e66c22623e26c3c815a3939eed5ccccd523380d3"
"footprint": "37c458d8aafebdfdb4745ceea8b218cc5ff4bbe1"
},
"documentationUrl": "https://docs.unity3d.com/Packages/[email protected]/manual/index.html",
"repository": {
"url": "https://github.cds.internal.unity3d.com/unity/Addressables.git",
"type": "git",
"revision": "8477325d1db715bebb91f6f11dc0d5aa6ebde77d"
"revision": "da6584e77b95eb8c8cc350ad4d95cc1a1aff1a34"
}
}

0 comments on commit fc1b2d2

Please sign in to comment.