From 328a99ccee62db9665f519cdbaca1968bb31a474 Mon Sep 17 00:00:00 2001 From: locus Date: Mon, 5 Jun 2023 00:34:25 +0900 Subject: [PATCH] fix assets are abandoned --- Editor/AssetDependencyTree.cs | 19 +++++++------------ package.json | 2 +- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/Editor/AssetDependencyTree.cs b/Editor/AssetDependencyTree.cs index f52fec5..969d3fc 100644 --- a/Editor/AssetDependencyTree.cs +++ b/Editor/AssetDependencyTree.cs @@ -32,7 +32,7 @@ public static ProcessResult ProcessDependencyTree(IEnumerable context.AtlasedSprites = AssetDatabase.FindAssets("t:spriteatlas") .Select(guid => AssetDatabase.GUIDToAssetPath(guid)) .Where(path => SpriteAtlasExtensions.IsIncludeInBuild(AssetDatabase.LoadAssetAtPath(path))) - .SelectMany(path => AssetDatabase.GetDependencies(path, true).Select(dep => (path, dep))) + .SelectMany(path => AssetDatabase.GetDependencies(path, true).Where(dep => dep != path).Select(dep => (path, dep))) .GroupBy(tuple => tuple.dep) .ToDictionary(grp => grp.Key, grp => grp.Select(tuple => tuple.path).ToList()); #endif @@ -151,10 +151,7 @@ public class Node { public RootNode Root { get; protected set; } public string Path { get; private set; } - public Dictionary Children = new Dictionary(); public bool IsRoot => Root == this; - public bool HasChild => Children.Count > 0; - public Node(string path, RootNode root) { Root = root; @@ -164,7 +161,6 @@ public Node(string path, RootNode root) public void RemoveFromTree(Context context) { context.IndirectNodes.Remove(Path); - foreach (var kv in Children) kv.Value.RemoveFromTree(context); } public void CollectNodes(Context context, bool fromAtlas = false) @@ -172,14 +168,14 @@ public void CollectNodes(Context context, bool fromAtlas = false) var childDeps = AssetDatabase.GetDependencies(Path, false); #if BUNDLE_SPRITE_ATLAS + //if sprite atlas, set from atlas to true + //to prevent stack overflow + if(Path.EndsWith(".spriteatlas")) fromAtlas = true; + if(!fromAtlas && context.AtlasedSprites.TryGetValue(Path, out var atlases)) { childDeps = childDeps.Union(atlases).Distinct().ToArray(); } - - //if sprite atlas, set from atlas to true - //to prevent stack overflow - if(!fromAtlas && Path.EndsWith(".spriteatlas")) fromAtlas = true; #endif //if it's a scene unwarp placed prefab directly into the scene @@ -210,7 +206,6 @@ public void CollectNodes(Context context, bool fromAtlas = false) //if not, add to indirect node var childNode = new Node(child, Root); context.IndirectNodes.Add(child, childNode); - Children.Add(child, childNode); //continue collect childNode.CollectNodes(context, fromAtlas); @@ -219,8 +214,8 @@ public void CollectNodes(Context context, bool fromAtlas = false) //skip if it's from same bundle if (node.Root.BundleName == Root.BundleName) continue; - - node.RemoveFromTree(context); + + context.IndirectNodes.Remove(child); var newRoot = RootNode.CreateShared(child); //add deps diff --git a/package.json b/package.json index 401b36d..c1e3825 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.locus.bundlesystem", "displayName": "Locus Bundle System", - "version": "1.1.23", + "version": "1.1.24", "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": {