Skip to content

Commit

Permalink
fix shared bundles generation messes up original bundles asset names
Browse files Browse the repository at this point in the history
  • Loading branch information
cj-rhee committed Apr 24, 2023
1 parent 81a9be8 commit 8ce05e0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
20 changes: 13 additions & 7 deletions Editor/AssetDependencyTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ public static ProcessResult ProcessDependencyTree(List<AssetBundleBuild> bundles
{
var context = new Context() { FolderBasedSharedBundle = folderBasedSharedGeneration, GenerateSharedNodes = generateSharedNodes };
var rootNodesToProcess = new List<RootNode>();
var originalBundles = new HashSet<string>();

//collecting reference should be done after adding all root nodes
//if not, there might be false positive shared bundle that already exist in bundle defines
foreach(var bundle in bundles)
{
if(bundle.assetBundleName.StartsWith("Shared_")) throw new System.Exception($"Bundle name should not start with \"Shared\" : {bundle.assetBundleName}");
originalBundles.Add(bundle.assetBundleName);
var isLocal = localBundles?.Contains(bundle.assetBundleName) ?? false;
foreach(var asset in bundle.assetNames)
{
Expand All @@ -38,18 +41,21 @@ public static ProcessResult ProcessDependencyTree(List<AssetBundleBuild> bundles
//actually analize and create shared bundles
foreach (var node in rootNodesToProcess) node.CollectNodes(context);

bundles.Clear();
var dependencies = new Dictionary<string, List<string>>();

foreach(var grp in context.RootNodes.Select(kv => kv.Value).GroupBy(node => node.BundleName))
{
var assets = grp.Select(node => node.Path).ToArray();
bundles.Add(new AssetBundleBuild()
//we do not touch original bundles, as we don't do any modifiation there
if(!originalBundles.Contains(grp.Key))
{
assetBundleName = grp.Key,
assetNames = assets,
addressableNames = assets
});
var assets = grp.Select(node => node.Path).ToArray();
bundles.Add(new AssetBundleBuild()
{
assetBundleName = grp.Key,
assetNames = assets,
addressableNames = assets
});
}

var deps = grp.SelectMany(node => node.GetReferences().Select(refNode => refNode.BundleName)).Distinct().ToList();
dependencies.Add(grp.Key, deps);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.locus.bundlesystem",
"displayName": "Locus Bundle System",
"version": "1.1.20",
"version": "1.1.21",
"description": "Simpler Assetbundle Build System using Scriptable Build Pipeline. Alternative to Unity Addressables. \n Visit https://github.com/locus84/Locus-Bundle-System for more informations.",
"unity": "2018.4",
"dependencies": {
Expand Down

0 comments on commit 8ce05e0

Please sign in to comment.