修复使用错的 api

This commit is contained in:
StarBeats 2025-10-23 12:48:45 +08:00
parent 04e032164b
commit 6bc0bcd083

View File

@ -1,5 +1,4 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
namespace UnityFileApi namespace UnityFileApi
{ {
public static class DependencyTool public static class DependencyTool
@ -12,28 +11,7 @@ namespace UnityFileApi
public static List<string> GetDependencies(string path) public static List<string> GetDependencies(string path)
{ {
List<string> dependencies = new List<string>(); List<string> dependencies = new List<string>();
try
{
using var archive = UnityFileSystem.MountArchive(path, "/");
foreach (var node in archive.Nodes)
{
Console.WriteLine($"Processing {node.Path} {node.Size} {node.Flags}");
if (node.Flags.HasFlag(ArchiveNodeFlags.SerializedFile))
{
using (var serializedFile = UnityFileSystem.OpenSerializedFile(path))
{
foreach (var extRef in serializedFile.ExternalReferences)
{
dependencies.Add(extRef.Guid);
}
}
}
}
return dependencies;
}
catch (NotSupportedException)
{
// Try as SerializedFile // Try as SerializedFile
using (var serializedFile = UnityFileSystem.OpenSerializedFile(path)) using (var serializedFile = UnityFileSystem.OpenSerializedFile(path))
{ {
@ -42,8 +20,8 @@ namespace UnityFileApi
dependencies.Add(extRef.Guid); dependencies.Add(extRef.Guid);
} }
} }
return dependencies; return dependencies;
} }
} }
} }
}