Skip to content

Commit 328a99c

Browse files
committed
fix assets are abandoned
1 parent 6729bdb commit 328a99c

2 files changed

Lines changed: 8 additions & 13 deletions

File tree

Editor/AssetDependencyTree.cs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static ProcessResult ProcessDependencyTree(IEnumerable<AssetBundleBuild>
3232
context.AtlasedSprites = AssetDatabase.FindAssets("t:spriteatlas")
3333
.Select(guid => AssetDatabase.GUIDToAssetPath(guid))
3434
.Where(path => SpriteAtlasExtensions.IsIncludeInBuild(AssetDatabase.LoadAssetAtPath<SpriteAtlas>(path)))
35-
.SelectMany(path => AssetDatabase.GetDependencies(path, true).Select(dep => (path, dep)))
35+
.SelectMany(path => AssetDatabase.GetDependencies(path, true).Where(dep => dep != path).Select(dep => (path, dep)))
3636
.GroupBy(tuple => tuple.dep)
3737
.ToDictionary(grp => grp.Key, grp => grp.Select(tuple => tuple.path).ToList());
3838
#endif
@@ -151,10 +151,7 @@ public class Node
151151
{
152152
public RootNode Root { get; protected set; }
153153
public string Path { get; private set; }
154-
public Dictionary<string, Node> Children = new Dictionary<string, Node>();
155154
public bool IsRoot => Root == this;
156-
public bool HasChild => Children.Count > 0;
157-
158155
public Node(string path, RootNode root)
159156
{
160157
Root = root;
@@ -164,22 +161,21 @@ public Node(string path, RootNode root)
164161
public void RemoveFromTree(Context context)
165162
{
166163
context.IndirectNodes.Remove(Path);
167-
foreach (var kv in Children) kv.Value.RemoveFromTree(context);
168164
}
169165

170166
public void CollectNodes(Context context, bool fromAtlas = false)
171167
{
172168
var childDeps = AssetDatabase.GetDependencies(Path, false);
173169

174170
#if BUNDLE_SPRITE_ATLAS
171+
//if sprite atlas, set from atlas to true
172+
//to prevent stack overflow
173+
if(Path.EndsWith(".spriteatlas")) fromAtlas = true;
174+
175175
if(!fromAtlas && context.AtlasedSprites.TryGetValue(Path, out var atlases))
176176
{
177177
childDeps = childDeps.Union(atlases).Distinct().ToArray();
178178
}
179-
180-
//if sprite atlas, set from atlas to true
181-
//to prevent stack overflow
182-
if(!fromAtlas && Path.EndsWith(".spriteatlas")) fromAtlas = true;
183179
#endif
184180

185181
//if it's a scene unwarp placed prefab directly into the scene
@@ -210,7 +206,6 @@ public void CollectNodes(Context context, bool fromAtlas = false)
210206
//if not, add to indirect node
211207
var childNode = new Node(child, Root);
212208
context.IndirectNodes.Add(child, childNode);
213-
Children.Add(child, childNode);
214209

215210
//continue collect
216211
childNode.CollectNodes(context, fromAtlas);
@@ -219,8 +214,8 @@ public void CollectNodes(Context context, bool fromAtlas = false)
219214

220215
//skip if it's from same bundle
221216
if (node.Root.BundleName == Root.BundleName) continue;
222-
223-
node.RemoveFromTree(context);
217+
218+
context.IndirectNodes.Remove(child);
224219
var newRoot = RootNode.CreateShared(child);
225220

226221
//add deps

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.locus.bundlesystem",
33
"displayName": "Locus Bundle System",
4-
"version": "1.1.23",
4+
"version": "1.1.24",
55
"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.",
66
"unity": "2018.4",
77
"dependencies": {

0 commit comments

Comments
 (0)