修复使用错的 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,38 +11,17 @@ 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)) // Try as SerializedFile
{ using (var serializedFile = UnityFileSystem.OpenSerializedFile(path))
using (var serializedFile = UnityFileSystem.OpenSerializedFile(path))
{
foreach (var extRef in serializedFile.ExternalReferences)
{
dependencies.Add(extRef.Guid);
}
}
}
}
return dependencies;
}
catch (NotSupportedException)
{ {
// Try as SerializedFile foreach (var extRef in serializedFile.ExternalReferences)
using (var serializedFile = UnityFileSystem.OpenSerializedFile(path))
{ {
foreach (var extRef in serializedFile.ExternalReferences) dependencies.Add(extRef.Guid);
{
dependencies.Add(extRef.Guid);
}
} }
return dependencies;
} }
return dependencies;
} }
} }
} }