mirror of
https://github.com/StarBeat/UnityDependencyAnalyzer.git
synced 2026-03-08 05:35:27 +08:00
Compare commits
2 Commits
04e032164b
...
f6d3bf65bc
| Author | SHA1 | Date | |
|---|---|---|---|
| f6d3bf65bc | |||
| 6bc0bcd083 |
@ -1,5 +1,8 @@
|
||||
using AssetDependencyGraph;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.Json;
|
||||
using AssetDependencyGraph;
|
||||
using UnityFileApi;
|
||||
UnityFileSystem.Init();
|
||||
|
||||
switch (Environment.GetCommandLineArgs()[1])
|
||||
{
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
namespace UnityFileApi
|
||||
{
|
||||
public static class DependencyTool
|
||||
@ -12,38 +11,17 @@ namespace UnityFileApi
|
||||
public static List<string> GetDependencies(string path)
|
||||
{
|
||||
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
|
||||
using (var serializedFile = UnityFileSystem.OpenSerializedFile(path))
|
||||
{
|
||||
// Try as SerializedFile
|
||||
using (var serializedFile = UnityFileSystem.OpenSerializedFile(path))
|
||||
foreach (var extRef in serializedFile.ExternalReferences)
|
||||
{
|
||||
foreach (var extRef in serializedFile.ExternalReferences)
|
||||
{
|
||||
dependencies.Add(extRef.Guid);
|
||||
}
|
||||
dependencies.Add(extRef.Guid);
|
||||
}
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
return dependencies;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -152,7 +152,7 @@ namespace UnityFileApi
|
||||
[DllImport("UnityFileSystemApi",
|
||||
CallingConvention = CallingConvention.Cdecl,
|
||||
EntryPoint = "UFS_MountArchive")]
|
||||
public static extern ReturnCode MountArchive([MarshalAs(UnmanagedType.LPStr)] string path, [MarshalAs(UnmanagedType.LPStr)] string mountPoint, out UnityArchiveHandle handle);
|
||||
public static extern ReturnCode MountArchive([MarshalAs(UnmanagedType.LPUTF8Str)] string path, [MarshalAs(UnmanagedType.LPUTF8Str)] string mountPoint, out UnityArchiveHandle handle);
|
||||
|
||||
[DllImport("UnityFileSystemApi",
|
||||
CallingConvention = CallingConvention.Cdecl,
|
||||
@ -172,14 +172,14 @@ namespace UnityFileApi
|
||||
[DllImport("UnityFileSystemApi",
|
||||
CallingConvention = CallingConvention.Cdecl,
|
||||
EntryPoint = "UFS_CreateArchive")]
|
||||
public static extern ReturnCode CreateArchive([MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPStr)] string[] sourceFiles,
|
||||
[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPStr)] string[] aliases, bool[] isSerializedFile, int count,
|
||||
[MarshalAs(UnmanagedType.LPStr)] string archiveFile, CompressionType compression, out int crc);
|
||||
public static extern ReturnCode CreateArchive([MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPUTF8Str)] string[] sourceFiles,
|
||||
[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPUTF8Str)] string[] aliases, bool[] isSerializedFile, int count,
|
||||
[MarshalAs(UnmanagedType.LPUTF8Str)] string archiveFile, CompressionType compression, out int crc);
|
||||
|
||||
[DllImport("UnityFileSystemApi",
|
||||
CallingConvention = CallingConvention.Cdecl,
|
||||
EntryPoint = "UFS_OpenFile")]
|
||||
public static extern ReturnCode OpenFile([MarshalAs(UnmanagedType.LPStr)] string path, out UnityFileHandle handle);
|
||||
public static extern ReturnCode OpenFile([MarshalAs(UnmanagedType.LPUTF8Str)] string path, out UnityFileHandle handle);
|
||||
|
||||
[DllImport("UnityFileSystemApi",
|
||||
CallingConvention = CallingConvention.Cdecl, EntryPoint = "UFS_ReadFile")]
|
||||
@ -204,7 +204,7 @@ namespace UnityFileApi
|
||||
[DllImport("UnityFileSystemApi",
|
||||
CallingConvention = CallingConvention.Cdecl,
|
||||
EntryPoint = "UFS_OpenSerializedFile")]
|
||||
public static extern ReturnCode OpenSerializedFile([MarshalAs(UnmanagedType.LPStr)] string path, out SerializedFileHandle handle);
|
||||
public static extern ReturnCode OpenSerializedFile([MarshalAs(UnmanagedType.LPUTF8Str)] string path, out SerializedFileHandle handle);
|
||||
|
||||
[DllImport("UnityFileSystemApi",
|
||||
CallingConvention = CallingConvention.Cdecl,
|
||||
@ -239,8 +239,8 @@ namespace UnityFileApi
|
||||
[DllImport("UnityFileSystemApi",
|
||||
CallingConvention = CallingConvention.Cdecl,
|
||||
EntryPoint = "UFS_GetRefTypeTypeTree")]
|
||||
public static extern ReturnCode GetRefTypeTypeTree(SerializedFileHandle handle, [MarshalAs(UnmanagedType.LPStr)] string className,
|
||||
[MarshalAs(UnmanagedType.LPStr)] string namespaceName, [MarshalAs(UnmanagedType.LPStr)] string assemblyName, out TypeTreeHandle typeTree);
|
||||
public static extern ReturnCode GetRefTypeTypeTree(SerializedFileHandle handle, [MarshalAs(UnmanagedType.LPUTF8Str)] string className,
|
||||
[MarshalAs(UnmanagedType.LPUTF8Str)] string namespaceName, [MarshalAs(UnmanagedType.LPUTF8Str)] string assemblyName, out TypeTreeHandle typeTree);
|
||||
|
||||
[DllImport("UnityFileSystemApi",
|
||||
CallingConvention = CallingConvention.Cdecl,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user