Compare commits

..

2 Commits

Author SHA1 Message Date
f6d3bf65bc 似乎系统不是 utf-8 编码中文会报找不到文件 2025-10-23 13:29:59 +08:00
6bc0bcd083 修复使用错的 api 2025-10-23 12:48:45 +08:00
3 changed files with 19 additions and 38 deletions

View File

@ -1,5 +1,8 @@
using AssetDependencyGraph;
using System.Runtime.InteropServices;
using System.Text.Json;
using AssetDependencyGraph;
using UnityFileApi;
UnityFileSystem.Init();
switch (Environment.GetCommandLineArgs()[1])
{

View File

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
namespace UnityFileApi
{
public static class DependencyTool
@ -12,28 +11,7 @@ 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))
{
@ -42,8 +20,8 @@ namespace UnityFileApi
dependencies.Add(extRef.Guid);
}
}
return dependencies;
}
}
}
}

View File

@ -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,