Compare commits
278 Commits
v0.14.38.5
...
ak-v1.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e0d90d1b1e | ||
|
|
dd727758a8 | ||
|
|
d44ed315e3 | ||
|
|
a00c857ac3 | ||
|
|
5333757843 | ||
|
|
4747687bec | ||
|
|
5c2ac1a5e8 | ||
|
|
e2eae53ac0 | ||
|
|
87347e8b60 | ||
|
|
0fdbddea55 | ||
|
|
823190abb7 | ||
|
|
60aef1b8ed | ||
|
|
f82a73f018 | ||
|
|
d42a1879ab | ||
|
|
632e5f8d08 | ||
|
|
51d259464b | ||
|
|
efd06648ad | ||
|
|
b27482e22b | ||
|
|
d572bd0e64 | ||
|
|
e415740373 | ||
|
|
e30b9e9e89 | ||
|
|
45bf9251c9 | ||
|
|
9632e88115 | ||
|
|
bb19dd5019 | ||
|
|
75ebe67713 | ||
|
|
ed7b0a2415 | ||
|
|
22ab5c0633 | ||
|
|
a2bc935850 | ||
|
|
b6c6ceba1c | ||
|
|
7c0a6375b1 | ||
|
|
5c489c5f83 | ||
|
|
cb84c137e5 | ||
|
|
25c611fb9e | ||
|
|
6d3875cb2c | ||
|
|
be4ced77ea | ||
|
|
2bd762e8f4 | ||
|
|
a926644ff6 | ||
|
|
a4cdff5934 | ||
|
|
2e10e627b0 | ||
|
|
e216abd6be | ||
|
|
93c7e617d8 | ||
|
|
000916913e | ||
|
|
28f9744497 | ||
|
|
c3f99216b6 | ||
|
|
19c4835ea3 | ||
|
|
6b321da695 | ||
|
|
7cca301f7a | ||
|
|
5ac597c935 | ||
|
|
e90af43459 | ||
|
|
171962e61f | ||
|
|
c8a21838c9 | ||
|
|
cf67815d53 | ||
|
|
381a7d89ae | ||
|
|
572e3bf0d6 | ||
|
|
3d7d51b54f | ||
|
|
abbd27fde7 | ||
|
|
94c8b355fe | ||
|
|
4e41caf203 | ||
|
|
74a8555514 | ||
|
|
e1d883adf6 | ||
|
|
9784df0e16 | ||
|
|
4d919a2bfe | ||
|
|
6701f467b7 | ||
|
|
50f5da5554 | ||
|
|
2b6dcca9c8 | ||
|
|
0bdcb89b08 | ||
|
|
dcd7b98229 | ||
|
|
007e5c7e4d | ||
|
|
63564d5fff | ||
|
|
aea6cbc97f | ||
|
|
6d41693b85 | ||
|
|
5695afae7b | ||
|
|
bb9ea7d86b | ||
|
|
547659e151 | ||
|
|
2f8f57c1a6 | ||
|
|
b7d5d73f23 | ||
|
|
f0c237473c | ||
|
|
09947fd14f | ||
|
|
da216dace8 | ||
|
|
c7356875f9 | ||
|
|
02e46eaa0d | ||
|
|
b0bf5e0cfd | ||
|
|
11b9ca37da | ||
|
|
5944dd8c58 | ||
|
|
1c67e39504 | ||
|
|
2d81007556 | ||
|
|
4bae98813b | ||
|
|
90ec395b2a | ||
|
|
af3684bab8 | ||
|
|
1da51ac95b | ||
|
|
9e14f1ef00 | ||
|
|
4edadb19f8 | ||
|
|
44a1240f5f | ||
|
|
01957a9443 | ||
|
|
ad1b3b4911 | ||
|
|
0925751776 | ||
|
|
b59ba3ba94 | ||
|
|
67898c72ca | ||
|
|
0425423ca9 | ||
|
|
16a7107d4e | ||
|
|
10b7e84ffb | ||
|
|
679e7041a6 | ||
|
|
629c6248a4 | ||
|
|
7674081df7 | ||
|
|
fb574064c9 | ||
|
|
c52940abc4 | ||
|
|
5c662d64e4 | ||
|
|
b9cf95616b | ||
|
|
39490d4e03 | ||
|
|
a96d1a5d5d | ||
|
|
568daafc7f | ||
|
|
2a2216e2bf | ||
|
|
dfbe46e1e5 | ||
|
|
6a9aad510c | ||
|
|
fd21cafd29 | ||
|
|
ea09a8de64 | ||
|
|
7fa5b4f355 | ||
|
|
c22d92009a | ||
|
|
53f3e8232a | ||
|
|
2fe57a1c5d | ||
|
|
ded2dcd54e | ||
|
|
8ae3df6197 | ||
|
|
64d9718c34 | ||
|
|
220004c976 | ||
|
|
a324366be9 | ||
|
|
06b4ae9ffe | ||
|
|
77b056de5e | ||
|
|
344edb722f | ||
|
|
98c4d0c3ab | ||
|
|
23ac590648 | ||
|
|
54445475a3 | ||
|
|
7299bcba6d | ||
|
|
5487ff4e60 | ||
|
|
b3621a75b0 | ||
|
|
8b048b9e1e | ||
|
|
41a79f485f | ||
|
|
a060a392e7 | ||
|
|
0798af7c5c | ||
|
|
8ebfa16e19 | ||
|
|
d158e864b5 | ||
|
|
b70b5196e3 | ||
|
|
4f88841026 | ||
|
|
dc9429feac | ||
|
|
a3c16ed3d6 | ||
|
|
5b83eebdda | ||
|
|
1fcf7a4364 | ||
|
|
973d50ce8b | ||
|
|
50485a9bd3 | ||
|
|
dbb3d3fef7 | ||
|
|
e1cfff63c3 | ||
|
|
44514a4e10 | ||
|
|
b1205808e2 | ||
|
|
7d3a4a10fc | ||
|
|
b909857820 | ||
|
|
b674e66407 | ||
|
|
d7dcd3f405 | ||
|
|
44145e0b9c | ||
|
|
d4e21f824c | ||
|
|
e7a4604a65 | ||
|
|
74f2c3190b | ||
|
|
8d193a63cd | ||
|
|
e61a317185 | ||
|
|
f67965b1dd | ||
|
|
07a81d9bfe | ||
|
|
95fd1823c8 | ||
|
|
d25451d5b9 | ||
|
|
0e1a886e0b | ||
|
|
97b5f51f3a | ||
|
|
7295feda72 | ||
|
|
fe95c91759 | ||
|
|
d220315d9b | ||
|
|
a94caa5e34 | ||
|
|
3660b4ed67 | ||
|
|
3370f93037 | ||
|
|
80653711cd | ||
|
|
f0b23bbfe7 | ||
|
|
88c5804586 | ||
|
|
e501940f03 | ||
|
|
d4060cde6d | ||
|
|
582a779441 | ||
|
|
5fa4934787 | ||
|
|
18277fbea8 | ||
|
|
571ea2da4a | ||
|
|
9cbe91decb | ||
|
|
19c6c5fe73 | ||
|
|
792850dbb2 | ||
|
|
2ce9cae957 | ||
|
|
af5e50cfa9 | ||
|
|
ce1172ca9a | ||
|
|
a7e6d91f5b | ||
|
|
34a0af683a | ||
|
|
91410a33b1 | ||
|
|
d08b78c2cf | ||
|
|
2ef52afe1e | ||
|
|
05a41d2f1e | ||
|
|
34c38e1415 | ||
|
|
c85873b729 | ||
|
|
b146d251a7 | ||
|
|
3129d67fc1 | ||
|
|
850ba63a10 | ||
|
|
17b91984d6 | ||
|
|
7ab2cda120 | ||
|
|
4345885cc9 | ||
|
|
53720e37ab | ||
|
|
7c3cb36630 | ||
|
|
c1cddce031 | ||
|
|
973a1076e4 | ||
|
|
089e164756 | ||
|
|
c2b6691fd9 | ||
|
|
8dec094304 | ||
|
|
bedee240be | ||
|
|
d963d71b12 | ||
|
|
77a0c9c40a | ||
|
|
f3e406983b | ||
|
|
08b7bfcf9a | ||
|
|
57e4f7cefd | ||
|
|
c9cf2d188e | ||
|
|
ab98585b6a | ||
|
|
075d53a455 | ||
|
|
432116d834 | ||
|
|
caa45216ef | ||
|
|
c9394cd957 | ||
|
|
46c0e8ffe1 | ||
|
|
d14c232015 | ||
|
|
4002bdecb8 | ||
|
|
17259e00c7 | ||
|
|
44b02b92d8 | ||
|
|
251854cc41 | ||
|
|
6f7b77245d | ||
|
|
6d99f5ebf6 | ||
|
|
f1f2430f97 | ||
|
|
b52696c965 | ||
|
|
5fba52dc83 | ||
|
|
dfb74baf79 | ||
|
|
978e90a403 | ||
|
|
c17d7d6331 | ||
|
|
9fef18d6ea | ||
|
|
ee0cd4ab52 | ||
|
|
f904bc138b | ||
|
|
7ed5345b1b | ||
|
|
d7f652d572 | ||
|
|
32ce032655 | ||
|
|
e1cf36aa3c | ||
|
|
f644396a15 | ||
|
|
3e77c34bd5 | ||
|
|
052c60f629 | ||
|
|
a1f2e3e7fe | ||
|
|
32ee8b326f | ||
|
|
06ce479eb6 | ||
|
|
03f74bac64 | ||
|
|
344b675745 | ||
|
|
86590d95a5 | ||
|
|
bbea1341b2 | ||
|
|
ca60dd9834 | ||
|
|
7aa35b5b8c | ||
|
|
bd2decdb8f | ||
|
|
9b2c85bcae | ||
|
|
efbab7c43a | ||
|
|
729a8a8263 | ||
|
|
0ec29f62ca | ||
|
|
796317f9d9 | ||
|
|
7596dcc7cd | ||
|
|
422851cdab | ||
|
|
ec0a2a47f1 | ||
|
|
8ce5b947f6 | ||
|
|
419ca63f9d | ||
|
|
6fdb0c7b0e | ||
|
|
4e97b4b898 | ||
|
|
1766dcbdeb | ||
|
|
ef38471ff1 | ||
|
|
217a7993e9 | ||
|
|
0a41615763 | ||
|
|
9d34f668d5 | ||
|
|
9269a36725 | ||
|
|
813e8b10a6 | ||
|
|
84c75fadf5 | ||
|
|
c76e41b1ab | ||
|
|
fefeea5f35 |
57
.github/workflows/build.yml
vendored
Normal file
57
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
name: AssetStudioBuild
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: windows-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: microsoft/setup-msbuild@v1.1
|
||||||
|
|
||||||
|
- name: Download FBX SDK
|
||||||
|
run: |
|
||||||
|
md fbx
|
||||||
|
cd fbx
|
||||||
|
Invoke-WebRequest "https://damassets.autodesk.net/content/dam/autodesk/www/adn/fbx/2020-2-1/fbx202021_fbxsdk_vs2019_win.exe" -OutFile "fbxsdk.exe"
|
||||||
|
Start-Process -FilePath "fbxsdk.exe" /S -Wait
|
||||||
|
Invoke-WebRequest "https://damassets.autodesk.net/content/dam/autodesk/www/adn/fbx/2020-2-1/fbx202021_fbxsdk_vs2019_pdbs.exe" -OutFile "fbxpdb.exe"
|
||||||
|
Start-Process -FilePath "fbxpdb.exe" /S -Wait
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
- name: Nuget Restore
|
||||||
|
run: nuget restore
|
||||||
|
|
||||||
|
- name: Build .Net472
|
||||||
|
run: msbuild /p:Configuration=Release /p:TargetFramework=net472 /verbosity:minimal
|
||||||
|
|
||||||
|
- name: Build .Net5
|
||||||
|
run: msbuild /t:AssetStudioGUI:publish /p:Configuration=Release /p:TargetFramework=net5.0-windows /p:SelfContained=false /verbosity:minimal
|
||||||
|
|
||||||
|
- name: Build .Net6
|
||||||
|
run: msbuild /t:AssetStudioGUI:publish /p:Configuration=Release /p:TargetFramework=net6.0-windows /p:SelfContained=false /verbosity:minimal
|
||||||
|
|
||||||
|
- name: Upload .Net472 Artifact
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: AssetStudio.net472
|
||||||
|
path: AssetStudioGUI/bin/Release/net472
|
||||||
|
|
||||||
|
- name: Upload .Net5 Artifact
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: AssetStudio.net5
|
||||||
|
path: AssetStudioGUI/bin/Release/net5.0-windows/publish
|
||||||
|
|
||||||
|
- name: Upload .Net6 Artifact
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: AssetStudio.net6
|
||||||
|
path: AssetStudioGUI/bin/Release/net6.0-windows/publish
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -35,6 +35,9 @@ bld/
|
|||||||
# Visual Studio 2017 auto generated files
|
# Visual Studio 2017 auto generated files
|
||||||
Generated\ Files/
|
Generated\ Files/
|
||||||
|
|
||||||
|
# Launch Settings
|
||||||
|
*launchSettings.json
|
||||||
|
|
||||||
# MSTest test Results
|
# MSTest test Results
|
||||||
[Tt]est[Rr]esult*/
|
[Tt]est[Rr]esult*/
|
||||||
[Bb]uild[Ll]og.*
|
[Bb]uild[Ll]og.*
|
||||||
|
|||||||
11
AssetStudio.PInvoke/AssetStudio.PInvoke.csproj
Normal file
11
AssetStudio.PInvoke/AssetStudio.PInvoke.csproj
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFrameworks>net472;net6.0;net6.0-windows;net7.0;net7.0-windows;net8.0;net8.0-windows</TargetFrameworks>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<Version>1.1.0</Version>
|
||||||
|
<Copyright>Copyright © Perfare 2020-2022; Copyright © hozuki 2020</Copyright>
|
||||||
|
<DebugType>embedded</DebugType>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
66
AssetStudio.PInvoke/DllLoader.cs
Normal file
66
AssetStudio.PInvoke/DllLoader.cs
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
#if NETFRAMEWORK
|
||||||
|
namespace AssetStudio.PInvoke
|
||||||
|
{
|
||||||
|
public static class DllLoader
|
||||||
|
{
|
||||||
|
public static void PreloadDll(string dllName)
|
||||||
|
{
|
||||||
|
var localPath = Process.GetCurrentProcess().MainModule.FileName;
|
||||||
|
var localDir = Path.GetDirectoryName(localPath);
|
||||||
|
|
||||||
|
// Not using OperatingSystem.Platform.
|
||||||
|
// See: https://www.mono-project.com/docs/faq/technical/#how-to-detect-the-execution-platform
|
||||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
|
{
|
||||||
|
Win32.LoadDll(GetDirectedDllDirectory(localDir), dllName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetDirectedDllDirectory(string localDir)
|
||||||
|
{
|
||||||
|
var win32Path = Path.Combine("runtimes", "win-x86", "native");
|
||||||
|
var win64Path = Path.Combine("runtimes", "win-x64", "native");
|
||||||
|
var subDir = Environment.Is64BitProcess ? win64Path : win32Path;
|
||||||
|
|
||||||
|
var directedDllDir = Path.Combine(localDir, subDir);
|
||||||
|
|
||||||
|
return directedDllDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Win32
|
||||||
|
{
|
||||||
|
|
||||||
|
internal static void LoadDll(string dllDir, string dllName)
|
||||||
|
{
|
||||||
|
var dllFileName = $"{dllName}.dll";
|
||||||
|
var directedDllPath = Path.Combine(dllDir, dllFileName);
|
||||||
|
|
||||||
|
// Specify SEARCH_DLL_LOAD_DIR to load dependent libraries located in the same platform-specific directory.
|
||||||
|
var hLibrary = LoadLibraryEx(directedDllPath, IntPtr.Zero, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR);
|
||||||
|
|
||||||
|
if (hLibrary == IntPtr.Zero)
|
||||||
|
{
|
||||||
|
var errorCode = Marshal.GetLastWin32Error();
|
||||||
|
var exception = new Win32Exception(errorCode);
|
||||||
|
|
||||||
|
throw new DllNotFoundException(exception.Message, exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// HMODULE LoadLibraryExA(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags);
|
||||||
|
// HMODULE LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags);
|
||||||
|
[DllImport("kernel32.dll", SetLastError = true)]
|
||||||
|
private static extern IntPtr LoadLibraryEx(string lpLibFileName, IntPtr hFile, uint dwFlags);
|
||||||
|
|
||||||
|
private const uint LOAD_LIBRARY_SEARCH_DEFAULT_DIRS = 0x1000;
|
||||||
|
private const uint LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR = 0x100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
100
AssetStudio.PInvoke/Utf8StringHandle.cs
Normal file
100
AssetStudio.PInvoke/Utf8StringHandle.cs
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
using Microsoft.Win32.SafeHandles;
|
||||||
|
|
||||||
|
namespace AssetStudio.PInvoke
|
||||||
|
{
|
||||||
|
// Generally the technique from Steamworks.NET
|
||||||
|
public class Utf8StringHandle : SafeHandleZeroOrMinusOneIsInvalid
|
||||||
|
{
|
||||||
|
|
||||||
|
static Utf8StringHandle()
|
||||||
|
{
|
||||||
|
Utf8 = new UTF8Encoding(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Utf8StringHandle(string str)
|
||||||
|
: base(true)
|
||||||
|
{
|
||||||
|
IntPtr buffer;
|
||||||
|
|
||||||
|
if (str == null)
|
||||||
|
{
|
||||||
|
buffer = IntPtr.Zero;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (str.Length == 0)
|
||||||
|
{
|
||||||
|
buffer = Marshal.AllocHGlobal(1);
|
||||||
|
|
||||||
|
unsafe
|
||||||
|
{
|
||||||
|
*(byte*)buffer = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var strlen = Utf8.GetByteCount(str);
|
||||||
|
var strBuffer = new byte[strlen + 1];
|
||||||
|
|
||||||
|
Utf8.GetBytes(str, 0, str.Length, strBuffer, 0);
|
||||||
|
|
||||||
|
buffer = Marshal.AllocHGlobal(strBuffer.Length);
|
||||||
|
|
||||||
|
Marshal.Copy(strBuffer, 0, buffer, strBuffer.Length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SetHandle(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string ReadUtf8StringFromPointer(IntPtr lpstr)
|
||||||
|
{
|
||||||
|
if (lpstr == IntPtr.Zero || lpstr == new IntPtr(-1))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var byteCount = 0;
|
||||||
|
|
||||||
|
unsafe
|
||||||
|
{
|
||||||
|
var p = (byte*)lpstr.ToPointer();
|
||||||
|
|
||||||
|
while (*p != 0)
|
||||||
|
{
|
||||||
|
byteCount += 1;
|
||||||
|
p += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (byteCount == 0)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
var strBuffer = new byte[byteCount];
|
||||||
|
|
||||||
|
Marshal.Copy(lpstr, strBuffer, 0, byteCount);
|
||||||
|
|
||||||
|
var str = Utf8.GetString(strBuffer);
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool ReleaseHandle()
|
||||||
|
{
|
||||||
|
if (!IsInvalid)
|
||||||
|
{
|
||||||
|
Marshal.FreeHGlobal(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static readonly UTF8Encoding Utf8;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
184
AssetStudio.sln
184
AssetStudio.sln
@@ -1,71 +1,159 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 16
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 16.0.29920.165
|
VisualStudioVersion = 17.5.33414.496
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssetStudio", "AssetStudio\AssetStudio.csproj", "{7662F8C2-7BFD-442E-A948-A43B4F7EB06E}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssetStudio", "AssetStudio\AssetStudio.csproj", "{422FEC21-EF60-4F29-AA56-95DFDA23C913}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AssetStudioFBX", "AssetStudioFBX\AssetStudioFBX.vcxproj", "{B82DD1BA-4EEC-4F29-A686-03D7F0DF39B8}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssetStudio.PInvoke", "AssetStudio.PInvoke\AssetStudio.PInvoke.csproj", "{0B2BE613-3049-4021-85D1-21C325F729F4}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Texture2DDecoder", "Texture2DDecoder\Texture2DDecoder.vcxproj", "{BEC7B5E6-0A7B-4824-97A7-EEA04D9EBA29}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssetStudioFBXWrapper", "AssetStudioFBXWrapper\AssetStudioFBXWrapper.csproj", "{E301AFEA-84E7-4BCE-8D65-A2576D8D105B}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{11EA25A3-ED68-40EE-A9D0-7FDE3B583027} = {11EA25A3-ED68-40EE-A9D0-7FDE3B583027}
|
||||||
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssetStudioUtility", "AssetStudioUtility\AssetStudioUtility.csproj", "{80AEC261-21EE-4E4F-A93B-7A744DC84888}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssetStudioGUI", "AssetStudioGUI\AssetStudioGUI.csproj", "{29EAD018-1C67-497A-AB8E-727D595AD756}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssetStudioGUI", "AssetStudioGUI\AssetStudioGUI.csproj", "{52B196FB-4C8A-499B-B877-1A0EB4F33EC0}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssetStudioUtility", "AssetStudioUtility\AssetStudioUtility.csproj", "{65EAFFA3-01D3-4EF5-B092-8B4647E9A1FF}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Texture2DDecoderWrapper", "Texture2DDecoderWrapper\Texture2DDecoderWrapper.csproj", "{6438FEC1-56B0-488C-A5E2-FBDB23E9574B}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{29356642-C46E-4144-83D8-22DC09D0D7FD} = {29356642-C46E-4144-83D8-22DC09D0D7FD}
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AssetStudioFBXNative", "AssetStudioFBXNative\AssetStudioFBXNative.vcxproj", "{11EA25A3-ED68-40EE-A9D0-7FDE3B583027}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Texture2DDecoderNative", "Texture2DDecoderNative\Texture2DDecoderNative.vcxproj", "{29356642-C46E-4144-83D8-22DC09D0D7FD}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssetStudioCLI", "AssetStudioCLI\AssetStudioCLI.csproj", "{34B6329B-0E73-45AC-B8CC-015F119F63DC}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{422FEC21-EF60-4F29-AA56-95DFDA23C913} = {422FEC21-EF60-4F29-AA56-95DFDA23C913}
|
||||||
|
{65EAFFA3-01D3-4EF5-B092-8B4647E9A1FF} = {65EAFFA3-01D3-4EF5-B092-8B4647E9A1FF}
|
||||||
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
Debug|x64 = Debug|x64
|
Debug|x64 = Debug|x64
|
||||||
Debug|x86 = Debug|x86
|
Debug|x86 = Debug|x86
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
Release|x64 = Release|x64
|
Release|x64 = Release|x64
|
||||||
Release|x86 = Release|x86
|
Release|x86 = Release|x86
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{7662F8C2-7BFD-442E-A948-A43B4F7EB06E}.Debug|x64.ActiveCfg = Debug|Any CPU
|
{422FEC21-EF60-4F29-AA56-95DFDA23C913}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{7662F8C2-7BFD-442E-A948-A43B4F7EB06E}.Debug|x64.Build.0 = Debug|Any CPU
|
{422FEC21-EF60-4F29-AA56-95DFDA23C913}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{7662F8C2-7BFD-442E-A948-A43B4F7EB06E}.Debug|x86.ActiveCfg = Debug|Any CPU
|
{422FEC21-EF60-4F29-AA56-95DFDA23C913}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
{7662F8C2-7BFD-442E-A948-A43B4F7EB06E}.Debug|x86.Build.0 = Debug|Any CPU
|
{422FEC21-EF60-4F29-AA56-95DFDA23C913}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
{7662F8C2-7BFD-442E-A948-A43B4F7EB06E}.Release|x64.ActiveCfg = Release|Any CPU
|
{422FEC21-EF60-4F29-AA56-95DFDA23C913}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
{7662F8C2-7BFD-442E-A948-A43B4F7EB06E}.Release|x64.Build.0 = Release|Any CPU
|
{422FEC21-EF60-4F29-AA56-95DFDA23C913}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
{7662F8C2-7BFD-442E-A948-A43B4F7EB06E}.Release|x86.ActiveCfg = Release|Any CPU
|
{422FEC21-EF60-4F29-AA56-95DFDA23C913}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{7662F8C2-7BFD-442E-A948-A43B4F7EB06E}.Release|x86.Build.0 = Release|Any CPU
|
{422FEC21-EF60-4F29-AA56-95DFDA23C913}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{B82DD1BA-4EEC-4F29-A686-03D7F0DF39B8}.Debug|x64.ActiveCfg = Debug|x64
|
{422FEC21-EF60-4F29-AA56-95DFDA23C913}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
{B82DD1BA-4EEC-4F29-A686-03D7F0DF39B8}.Debug|x64.Build.0 = Debug|x64
|
{422FEC21-EF60-4F29-AA56-95DFDA23C913}.Release|x64.Build.0 = Release|Any CPU
|
||||||
{B82DD1BA-4EEC-4F29-A686-03D7F0DF39B8}.Debug|x86.ActiveCfg = Debug|Win32
|
{422FEC21-EF60-4F29-AA56-95DFDA23C913}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{B82DD1BA-4EEC-4F29-A686-03D7F0DF39B8}.Debug|x86.Build.0 = Debug|Win32
|
{422FEC21-EF60-4F29-AA56-95DFDA23C913}.Release|x86.Build.0 = Release|Any CPU
|
||||||
{B82DD1BA-4EEC-4F29-A686-03D7F0DF39B8}.Release|x64.ActiveCfg = Release|x64
|
{0B2BE613-3049-4021-85D1-21C325F729F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{B82DD1BA-4EEC-4F29-A686-03D7F0DF39B8}.Release|x64.Build.0 = Release|x64
|
{0B2BE613-3049-4021-85D1-21C325F729F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{B82DD1BA-4EEC-4F29-A686-03D7F0DF39B8}.Release|x86.ActiveCfg = Release|Win32
|
{0B2BE613-3049-4021-85D1-21C325F729F4}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
{B82DD1BA-4EEC-4F29-A686-03D7F0DF39B8}.Release|x86.Build.0 = Release|Win32
|
{0B2BE613-3049-4021-85D1-21C325F729F4}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
{BEC7B5E6-0A7B-4824-97A7-EEA04D9EBA29}.Debug|x64.ActiveCfg = Debug|x64
|
{0B2BE613-3049-4021-85D1-21C325F729F4}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
{BEC7B5E6-0A7B-4824-97A7-EEA04D9EBA29}.Debug|x64.Build.0 = Debug|x64
|
{0B2BE613-3049-4021-85D1-21C325F729F4}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
{BEC7B5E6-0A7B-4824-97A7-EEA04D9EBA29}.Debug|x86.ActiveCfg = Debug|Win32
|
{0B2BE613-3049-4021-85D1-21C325F729F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{BEC7B5E6-0A7B-4824-97A7-EEA04D9EBA29}.Debug|x86.Build.0 = Debug|Win32
|
{0B2BE613-3049-4021-85D1-21C325F729F4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{BEC7B5E6-0A7B-4824-97A7-EEA04D9EBA29}.Release|x64.ActiveCfg = Release|x64
|
{0B2BE613-3049-4021-85D1-21C325F729F4}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
{BEC7B5E6-0A7B-4824-97A7-EEA04D9EBA29}.Release|x64.Build.0 = Release|x64
|
{0B2BE613-3049-4021-85D1-21C325F729F4}.Release|x64.Build.0 = Release|Any CPU
|
||||||
{BEC7B5E6-0A7B-4824-97A7-EEA04D9EBA29}.Release|x86.ActiveCfg = Release|Win32
|
{0B2BE613-3049-4021-85D1-21C325F729F4}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{BEC7B5E6-0A7B-4824-97A7-EEA04D9EBA29}.Release|x86.Build.0 = Release|Win32
|
{0B2BE613-3049-4021-85D1-21C325F729F4}.Release|x86.Build.0 = Release|Any CPU
|
||||||
{80AEC261-21EE-4E4F-A93B-7A744DC84888}.Debug|x64.ActiveCfg = Debug|x64
|
{E301AFEA-84E7-4BCE-8D65-A2576D8D105B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{80AEC261-21EE-4E4F-A93B-7A744DC84888}.Debug|x64.Build.0 = Debug|x64
|
{E301AFEA-84E7-4BCE-8D65-A2576D8D105B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{80AEC261-21EE-4E4F-A93B-7A744DC84888}.Debug|x86.ActiveCfg = Debug|x86
|
{E301AFEA-84E7-4BCE-8D65-A2576D8D105B}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
{80AEC261-21EE-4E4F-A93B-7A744DC84888}.Debug|x86.Build.0 = Debug|x86
|
{E301AFEA-84E7-4BCE-8D65-A2576D8D105B}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
{80AEC261-21EE-4E4F-A93B-7A744DC84888}.Release|x64.ActiveCfg = Release|x64
|
{E301AFEA-84E7-4BCE-8D65-A2576D8D105B}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
{80AEC261-21EE-4E4F-A93B-7A744DC84888}.Release|x64.Build.0 = Release|x64
|
{E301AFEA-84E7-4BCE-8D65-A2576D8D105B}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
{80AEC261-21EE-4E4F-A93B-7A744DC84888}.Release|x86.ActiveCfg = Release|x86
|
{E301AFEA-84E7-4BCE-8D65-A2576D8D105B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{80AEC261-21EE-4E4F-A93B-7A744DC84888}.Release|x86.Build.0 = Release|x86
|
{E301AFEA-84E7-4BCE-8D65-A2576D8D105B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{52B196FB-4C8A-499B-B877-1A0EB4F33EC0}.Debug|x64.ActiveCfg = Debug|x64
|
{E301AFEA-84E7-4BCE-8D65-A2576D8D105B}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
{52B196FB-4C8A-499B-B877-1A0EB4F33EC0}.Debug|x64.Build.0 = Debug|x64
|
{E301AFEA-84E7-4BCE-8D65-A2576D8D105B}.Release|x64.Build.0 = Release|Any CPU
|
||||||
{52B196FB-4C8A-499B-B877-1A0EB4F33EC0}.Debug|x86.ActiveCfg = Debug|x86
|
{E301AFEA-84E7-4BCE-8D65-A2576D8D105B}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{52B196FB-4C8A-499B-B877-1A0EB4F33EC0}.Debug|x86.Build.0 = Debug|x86
|
{E301AFEA-84E7-4BCE-8D65-A2576D8D105B}.Release|x86.Build.0 = Release|Any CPU
|
||||||
{52B196FB-4C8A-499B-B877-1A0EB4F33EC0}.Release|x64.ActiveCfg = Release|x64
|
{29EAD018-1C67-497A-AB8E-727D595AD756}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{52B196FB-4C8A-499B-B877-1A0EB4F33EC0}.Release|x64.Build.0 = Release|x64
|
{29EAD018-1C67-497A-AB8E-727D595AD756}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{52B196FB-4C8A-499B-B877-1A0EB4F33EC0}.Release|x86.ActiveCfg = Release|x86
|
{29EAD018-1C67-497A-AB8E-727D595AD756}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
{52B196FB-4C8A-499B-B877-1A0EB4F33EC0}.Release|x86.Build.0 = Release|x86
|
{29EAD018-1C67-497A-AB8E-727D595AD756}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{29EAD018-1C67-497A-AB8E-727D595AD756}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{29EAD018-1C67-497A-AB8E-727D595AD756}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{29EAD018-1C67-497A-AB8E-727D595AD756}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{29EAD018-1C67-497A-AB8E-727D595AD756}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{29EAD018-1C67-497A-AB8E-727D595AD756}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{29EAD018-1C67-497A-AB8E-727D595AD756}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{29EAD018-1C67-497A-AB8E-727D595AD756}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{29EAD018-1C67-497A-AB8E-727D595AD756}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{65EAFFA3-01D3-4EF5-B092-8B4647E9A1FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{65EAFFA3-01D3-4EF5-B092-8B4647E9A1FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{65EAFFA3-01D3-4EF5-B092-8B4647E9A1FF}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{65EAFFA3-01D3-4EF5-B092-8B4647E9A1FF}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{65EAFFA3-01D3-4EF5-B092-8B4647E9A1FF}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{65EAFFA3-01D3-4EF5-B092-8B4647E9A1FF}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{65EAFFA3-01D3-4EF5-B092-8B4647E9A1FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{65EAFFA3-01D3-4EF5-B092-8B4647E9A1FF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{65EAFFA3-01D3-4EF5-B092-8B4647E9A1FF}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{65EAFFA3-01D3-4EF5-B092-8B4647E9A1FF}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{65EAFFA3-01D3-4EF5-B092-8B4647E9A1FF}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{65EAFFA3-01D3-4EF5-B092-8B4647E9A1FF}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{6438FEC1-56B0-488C-A5E2-FBDB23E9574B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{6438FEC1-56B0-488C-A5E2-FBDB23E9574B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{6438FEC1-56B0-488C-A5E2-FBDB23E9574B}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{6438FEC1-56B0-488C-A5E2-FBDB23E9574B}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{6438FEC1-56B0-488C-A5E2-FBDB23E9574B}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{6438FEC1-56B0-488C-A5E2-FBDB23E9574B}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{6438FEC1-56B0-488C-A5E2-FBDB23E9574B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{6438FEC1-56B0-488C-A5E2-FBDB23E9574B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{6438FEC1-56B0-488C-A5E2-FBDB23E9574B}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{6438FEC1-56B0-488C-A5E2-FBDB23E9574B}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{6438FEC1-56B0-488C-A5E2-FBDB23E9574B}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{6438FEC1-56B0-488C-A5E2-FBDB23E9574B}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{11EA25A3-ED68-40EE-A9D0-7FDE3B583027}.Debug|Any CPU.ActiveCfg = Debug|Win32
|
||||||
|
{11EA25A3-ED68-40EE-A9D0-7FDE3B583027}.Debug|Any CPU.Build.0 = Debug|Win32
|
||||||
|
{11EA25A3-ED68-40EE-A9D0-7FDE3B583027}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{11EA25A3-ED68-40EE-A9D0-7FDE3B583027}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{11EA25A3-ED68-40EE-A9D0-7FDE3B583027}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{11EA25A3-ED68-40EE-A9D0-7FDE3B583027}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{11EA25A3-ED68-40EE-A9D0-7FDE3B583027}.Release|Any CPU.ActiveCfg = Release|Win32
|
||||||
|
{11EA25A3-ED68-40EE-A9D0-7FDE3B583027}.Release|Any CPU.Build.0 = Release|Win32
|
||||||
|
{11EA25A3-ED68-40EE-A9D0-7FDE3B583027}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{11EA25A3-ED68-40EE-A9D0-7FDE3B583027}.Release|x64.Build.0 = Release|x64
|
||||||
|
{11EA25A3-ED68-40EE-A9D0-7FDE3B583027}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{11EA25A3-ED68-40EE-A9D0-7FDE3B583027}.Release|x86.Build.0 = Release|Win32
|
||||||
|
{29356642-C46E-4144-83D8-22DC09D0D7FD}.Debug|Any CPU.ActiveCfg = Debug|Win32
|
||||||
|
{29356642-C46E-4144-83D8-22DC09D0D7FD}.Debug|Any CPU.Build.0 = Debug|Win32
|
||||||
|
{29356642-C46E-4144-83D8-22DC09D0D7FD}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{29356642-C46E-4144-83D8-22DC09D0D7FD}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{29356642-C46E-4144-83D8-22DC09D0D7FD}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{29356642-C46E-4144-83D8-22DC09D0D7FD}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{29356642-C46E-4144-83D8-22DC09D0D7FD}.Release|Any CPU.ActiveCfg = Release|Win32
|
||||||
|
{29356642-C46E-4144-83D8-22DC09D0D7FD}.Release|Any CPU.Build.0 = Release|Win32
|
||||||
|
{29356642-C46E-4144-83D8-22DC09D0D7FD}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{29356642-C46E-4144-83D8-22DC09D0D7FD}.Release|x64.Build.0 = Release|x64
|
||||||
|
{29356642-C46E-4144-83D8-22DC09D0D7FD}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{29356642-C46E-4144-83D8-22DC09D0D7FD}.Release|x86.Build.0 = Release|Win32
|
||||||
|
{34B6329B-0E73-45AC-B8CC-015F119F63DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{34B6329B-0E73-45AC-B8CC-015F119F63DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{34B6329B-0E73-45AC-B8CC-015F119F63DC}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{34B6329B-0E73-45AC-B8CC-015F119F63DC}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{34B6329B-0E73-45AC-B8CC-015F119F63DC}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{34B6329B-0E73-45AC-B8CC-015F119F63DC}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{34B6329B-0E73-45AC-B8CC-015F119F63DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{34B6329B-0E73-45AC-B8CC-015F119F63DC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{34B6329B-0E73-45AC-B8CC-015F119F63DC}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{34B6329B-0E73-45AC-B8CC-015F119F63DC}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{34B6329B-0E73-45AC-B8CC-015F119F63DC}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{34B6329B-0E73-45AC-B8CC-015F119F63DC}.Release|x86.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {F8734F96-97B6-40CA-B791-6D5467F2F713}
|
SolutionGuid = {3C074481-9CDD-4780-B9F6-57BBC5092EA2}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
@@ -1,154 +1,20 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<TargetFrameworks>net472;net6.0;net6.0-windows;net7.0;net7.0-windows;net8.0;net8.0-windows</TargetFrameworks>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Version>1.1.0</Version>
|
||||||
<ProjectGuid>{7662F8C2-7BFD-442E-A948-A43B4F7EB06E}</ProjectGuid>
|
<Copyright>Copyright © Perfare 2018-2022; Copyright © aelurum 2023</Copyright>
|
||||||
<OutputType>Library</OutputType>
|
<DebugType>embedded</DebugType>
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
|
||||||
<RootNamespace>AssetStudio</RootNamespace>
|
|
||||||
<AssemblyName>AssetStudio</AssemblyName>
|
|
||||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
|
||||||
<FileAlignment>512</FileAlignment>
|
|
||||||
<Deterministic>true</Deterministic>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<ItemGroup Condition=" '$(TargetFramework)' != 'net472' ">
|
||||||
<DebugType>full</DebugType>
|
<PackageReference Include="K4os.Compression.LZ4" Version="1.3.6" />
|
||||||
<Optimize>false</Optimize>
|
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
|
||||||
<DebugType>none</DebugType>
|
|
||||||
<Optimize>true</Optimize>
|
|
||||||
<OutputPath>bin\Release\</OutputPath>
|
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="System" />
|
|
||||||
<Reference Include="System.Core" />
|
|
||||||
<Reference Include="System.Drawing" />
|
|
||||||
<Reference Include="System.Xml.Linq" />
|
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
|
||||||
<Reference Include="System.Data" />
|
|
||||||
<Reference Include="System.Net.Http" />
|
|
||||||
<Reference Include="System.Xml" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<Compile Include="7zip\Common\CommandLineParser.cs" />
|
<ItemGroup Condition=" '$(TargetFramework)' == 'net472' ">
|
||||||
<Compile Include="7zip\Common\CRC.cs" />
|
<PackageReference Include="System.Memory" Version="4.5.4" />
|
||||||
<Compile Include="7zip\Common\InBuffer.cs" />
|
<PackageReference Include="System.IO.Compression" Version="4.0.0" />
|
||||||
<Compile Include="7zip\Common\OutBuffer.cs" />
|
<PackageReference Include="K4os.Compression.LZ4" Version="1.1.11" />
|
||||||
<Compile Include="7zip\Compress\LZMA\LzmaBase.cs" />
|
|
||||||
<Compile Include="7zip\Compress\LZMA\LzmaDecoder.cs" />
|
|
||||||
<Compile Include="7zip\Compress\LZMA\LzmaEncoder.cs" />
|
|
||||||
<Compile Include="7zip\Compress\LZ\IMatchFinder.cs" />
|
|
||||||
<Compile Include="7zip\Compress\LZ\LzBinTree.cs" />
|
|
||||||
<Compile Include="7zip\Compress\LZ\LzInWindow.cs" />
|
|
||||||
<Compile Include="7zip\Compress\LZ\LzOutWindow.cs" />
|
|
||||||
<Compile Include="7zip\Compress\RangeCoder\RangeCoder.cs" />
|
|
||||||
<Compile Include="7zip\Compress\RangeCoder\RangeCoderBit.cs" />
|
|
||||||
<Compile Include="7zip\Compress\RangeCoder\RangeCoderBitTree.cs" />
|
|
||||||
<Compile Include="7zip\ICoder.cs" />
|
|
||||||
<Compile Include="AssetsManager.cs" />
|
|
||||||
<Compile Include="Brotli\BitReader.cs" />
|
|
||||||
<Compile Include="Brotli\BrotliInputStream.cs" />
|
|
||||||
<Compile Include="Brotli\BrotliRuntimeException.cs" />
|
|
||||||
<Compile Include="Brotli\Context.cs" />
|
|
||||||
<Compile Include="Brotli\Decode.cs" />
|
|
||||||
<Compile Include="Brotli\Dictionary.cs" />
|
|
||||||
<Compile Include="Brotli\Huffman.cs" />
|
|
||||||
<Compile Include="Brotli\HuffmanTreeGroup.cs" />
|
|
||||||
<Compile Include="Brotli\IntReader.cs" />
|
|
||||||
<Compile Include="Brotli\Prefix.cs" />
|
|
||||||
<Compile Include="Brotli\RunningState.cs" />
|
|
||||||
<Compile Include="Brotli\State.cs" />
|
|
||||||
<Compile Include="Brotli\Transform.cs" />
|
|
||||||
<Compile Include="Brotli\Utils.cs" />
|
|
||||||
<Compile Include="Brotli\WordTransformType.cs" />
|
|
||||||
<Compile Include="BuildTarget.cs" />
|
|
||||||
<Compile Include="BuildType.cs" />
|
|
||||||
<Compile Include="BundleFile.cs" />
|
|
||||||
<Compile Include="Classes\Animation.cs" />
|
|
||||||
<Compile Include="Classes\AnimationClip.cs" />
|
|
||||||
<Compile Include="Classes\Animator.cs" />
|
|
||||||
<Compile Include="Classes\AnimatorController.cs" />
|
|
||||||
<Compile Include="Classes\AnimatorOverrideController.cs" />
|
|
||||||
<Compile Include="Classes\AssetBundle.cs" />
|
|
||||||
<Compile Include="Classes\AudioClip.cs" />
|
|
||||||
<Compile Include="Classes\Avatar.cs" />
|
|
||||||
<Compile Include="Classes\Behaviour.cs" />
|
|
||||||
<Compile Include="Classes\BuildSettings.cs" />
|
|
||||||
<Compile Include="Classes\Component.cs" />
|
|
||||||
<Compile Include="Classes\EditorExtension.cs" />
|
|
||||||
<Compile Include="Classes\Font.cs" />
|
|
||||||
<Compile Include="Classes\GameObject.cs" />
|
|
||||||
<Compile Include="Classes\Material.cs" />
|
|
||||||
<Compile Include="Classes\Mesh.cs" />
|
|
||||||
<Compile Include="Classes\MeshFilter.cs" />
|
|
||||||
<Compile Include="Classes\MeshRenderer.cs" />
|
|
||||||
<Compile Include="Classes\MonoBehaviour.cs" />
|
|
||||||
<Compile Include="Classes\MonoScript.cs" />
|
|
||||||
<Compile Include="Classes\MovieTexture.cs" />
|
|
||||||
<Compile Include="Classes\NamedObject.cs" />
|
|
||||||
<Compile Include="Classes\Object.cs" />
|
|
||||||
<Compile Include="Classes\PlayerSettings.cs" />
|
|
||||||
<Compile Include="Classes\PPtr.cs" />
|
|
||||||
<Compile Include="Classes\RectTransform.cs" />
|
|
||||||
<Compile Include="Classes\Renderer.cs" />
|
|
||||||
<Compile Include="Classes\RuntimeAnimatorController.cs" />
|
|
||||||
<Compile Include="Classes\Shader.cs" />
|
|
||||||
<Compile Include="Classes\SkinnedMeshRenderer.cs" />
|
|
||||||
<Compile Include="Classes\Sprite.cs" />
|
|
||||||
<Compile Include="Classes\SpriteAtlas.cs" />
|
|
||||||
<Compile Include="Classes\TextAsset.cs" />
|
|
||||||
<Compile Include="Classes\Texture.cs" />
|
|
||||||
<Compile Include="Classes\Texture2D.cs" />
|
|
||||||
<Compile Include="Classes\Transform.cs" />
|
|
||||||
<Compile Include="Classes\VideoClip.cs" />
|
|
||||||
<Compile Include="ClassIDType.cs" />
|
|
||||||
<Compile Include="CommonString.cs" />
|
|
||||||
<Compile Include="EndianBinaryReader.cs" />
|
|
||||||
<Compile Include="Extensions\BinaryReaderExtensions.cs" />
|
|
||||||
<Compile Include="Extensions\BinaryWriterExtensions.cs" />
|
|
||||||
<Compile Include="Extensions\StreamExtensions.cs" />
|
|
||||||
<Compile Include="FileIdentifier.cs" />
|
|
||||||
<Compile Include="IImported.cs" />
|
|
||||||
<Compile Include="ILogger.cs" />
|
|
||||||
<Compile Include="ImportHelper.cs" />
|
|
||||||
<Compile Include="IProgress.cs" />
|
|
||||||
<Compile Include="LocalSerializedObjectIdentifier.cs" />
|
|
||||||
<Compile Include="Logger.cs" />
|
|
||||||
<Compile Include="Lz4DecoderStream.cs" />
|
|
||||||
<Compile Include="Math\Color.cs" />
|
|
||||||
<Compile Include="Math\Half.cs" />
|
|
||||||
<Compile Include="Math\HalfHelper.cs" />
|
|
||||||
<Compile Include="Math\Matrix4x4.cs" />
|
|
||||||
<Compile Include="Math\Quaternion.cs" />
|
|
||||||
<Compile Include="Math\Vector2.cs" />
|
|
||||||
<Compile Include="Math\Vector3.cs" />
|
|
||||||
<Compile Include="Math\Vector4.cs" />
|
|
||||||
<Compile Include="ObjectInfo.cs" />
|
|
||||||
<Compile Include="ObjectReader.cs" />
|
|
||||||
<Compile Include="Progress.cs" />
|
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
|
||||||
<Compile Include="ResourceReader.cs" />
|
|
||||||
<Compile Include="SerializedFile.cs" />
|
|
||||||
<Compile Include="SerializedFileHeader.cs" />
|
|
||||||
<Compile Include="SerializedType.cs" />
|
|
||||||
<Compile Include="SevenZipHelper.cs" />
|
|
||||||
<Compile Include="StreamFile.cs" />
|
|
||||||
<Compile Include="TypeTreeHelper.cs" />
|
|
||||||
<Compile Include="TypeTreeNode.cs" />
|
|
||||||
<Compile Include="UType.cs" />
|
|
||||||
<Compile Include="WebFile.cs" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,34 +1,108 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.IO.Compression;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
using static AssetStudio.ImportHelper;
|
using static AssetStudio.ImportHelper;
|
||||||
|
|
||||||
namespace AssetStudio
|
namespace AssetStudio
|
||||||
{
|
{
|
||||||
public class AssetsManager
|
public class AssetsManager
|
||||||
{
|
{
|
||||||
|
public string SpecifyUnityVersion;
|
||||||
public List<SerializedFile> assetsFileList = new List<SerializedFile>();
|
public List<SerializedFile> assetsFileList = new List<SerializedFile>();
|
||||||
|
private HashSet<ClassIDType> filteredAssetTypesList = new HashSet<ClassIDType>();
|
||||||
|
|
||||||
internal Dictionary<string, int> assetsFileIndexCache = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
|
internal Dictionary<string, int> assetsFileIndexCache = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
|
||||||
internal Dictionary<string, BinaryReader> resourceFileReaders = new Dictionary<string, BinaryReader>(StringComparer.OrdinalIgnoreCase);
|
internal Dictionary<string, BinaryReader> resourceFileReaders = new Dictionary<string, BinaryReader>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
private List<string> importFiles = new List<string>();
|
private List<string> importFiles = new List<string>();
|
||||||
private HashSet<string> importFilesHash = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
private HashSet<string> importFilesHash = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
private HashSet<string> noexistFiles = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||||
private HashSet<string> assetsFileListHash = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
private HashSet<string> assetsFileListHash = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
public void LoadFiles(params string[] files)
|
public void SetAssetFilter(params ClassIDType[] classIDTypes)
|
||||||
{
|
{
|
||||||
var path = Path.GetDirectoryName(files[0]);
|
if (filteredAssetTypesList.Count == 0)
|
||||||
MergeSplitAssets(path);
|
{
|
||||||
var toReadFile = ProcessingSplitFiles(files.ToList());
|
filteredAssetTypesList.UnionWith(new HashSet<ClassIDType>
|
||||||
Load(toReadFile);
|
{
|
||||||
|
ClassIDType.AssetBundle,
|
||||||
|
ClassIDType.ResourceManager,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (classIDTypes.Contains(ClassIDType.MonoBehaviour))
|
||||||
|
{
|
||||||
|
filteredAssetTypesList.Add(ClassIDType.MonoScript);
|
||||||
|
}
|
||||||
|
if (classIDTypes.Contains(ClassIDType.Sprite) || classIDTypes.Contains(ClassIDType.AkPortraitSprite))
|
||||||
|
{
|
||||||
|
filteredAssetTypesList.UnionWith(new HashSet<ClassIDType>
|
||||||
|
{
|
||||||
|
ClassIDType.Texture2D,
|
||||||
|
ClassIDType.SpriteAtlas,
|
||||||
|
ClassIDType.MonoBehaviour,
|
||||||
|
ClassIDType.MonoScript
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
filteredAssetTypesList.UnionWith(classIDTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadFolder(string path)
|
public void SetAssetFilter(List<ClassIDType> classIDTypeList)
|
||||||
{
|
{
|
||||||
MergeSplitAssets(path, true);
|
SetAssetFilter(classIDTypeList.ToArray());
|
||||||
var files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories).ToList();
|
}
|
||||||
var toReadFile = ProcessingSplitFiles(files);
|
|
||||||
|
public void LoadFilesAndFolders(params string[] path)
|
||||||
|
{
|
||||||
|
List<string> pathList = new List<string>();
|
||||||
|
pathList.AddRange(path);
|
||||||
|
LoadFilesAndFolders(out _, pathList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadFilesAndFolders(out string parentPath, params string[] path)
|
||||||
|
{
|
||||||
|
List<string> pathList = new List<string>();
|
||||||
|
pathList.AddRange(path);
|
||||||
|
LoadFilesAndFolders(out parentPath, pathList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadFilesAndFolders(out string parentPath, List<string> pathList)
|
||||||
|
{
|
||||||
|
List<string> fileList = new List<string>();
|
||||||
|
bool filesInPath = false;
|
||||||
|
parentPath = "";
|
||||||
|
foreach (var path in pathList)
|
||||||
|
{
|
||||||
|
var fullPath = Path.GetFullPath(path);
|
||||||
|
if (Directory.Exists(fullPath))
|
||||||
|
{
|
||||||
|
var parent = Directory.GetParent(fullPath).FullName;
|
||||||
|
if (!filesInPath && (parentPath == "" || parentPath.Length > parent.Length))
|
||||||
|
{
|
||||||
|
parentPath = parent;
|
||||||
|
}
|
||||||
|
MergeSplitAssets(fullPath, true);
|
||||||
|
fileList.AddRange(Directory.GetFiles(fullPath, "*.*", SearchOption.AllDirectories));
|
||||||
|
}
|
||||||
|
else if (File.Exists(fullPath))
|
||||||
|
{
|
||||||
|
parentPath = Path.GetDirectoryName(fullPath);
|
||||||
|
fileList.Add(fullPath);
|
||||||
|
filesInPath = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (filesInPath)
|
||||||
|
{
|
||||||
|
MergeSplitAssets(parentPath);
|
||||||
|
}
|
||||||
|
var toReadFile = ProcessingSplitFiles(fileList);
|
||||||
|
fileList.Clear();
|
||||||
|
pathList.Clear();
|
||||||
|
|
||||||
Load(toReadFile);
|
Load(toReadFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,6 +124,7 @@ namespace AssetStudio
|
|||||||
|
|
||||||
importFiles.Clear();
|
importFiles.Clear();
|
||||||
importFilesHash.Clear();
|
importFilesHash.Clear();
|
||||||
|
noexistFiles.Clear();
|
||||||
assetsFileListHash.Clear();
|
assetsFileListHash.Clear();
|
||||||
|
|
||||||
ReadAssets();
|
ReadAssets();
|
||||||
@@ -58,121 +133,158 @@ namespace AssetStudio
|
|||||||
|
|
||||||
private void LoadFile(string fullName)
|
private void LoadFile(string fullName)
|
||||||
{
|
{
|
||||||
switch (CheckFileType(fullName, out var reader))
|
var reader = new FileReader(fullName);
|
||||||
|
LoadFile(reader);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadFile(FileReader reader)
|
||||||
|
{
|
||||||
|
switch (reader?.FileType)
|
||||||
{
|
{
|
||||||
case FileType.AssetsFile:
|
case FileType.AssetsFile:
|
||||||
LoadAssetsFile(fullName, reader);
|
LoadAssetsFile(reader);
|
||||||
break;
|
break;
|
||||||
case FileType.BundleFile:
|
case FileType.BundleFile:
|
||||||
LoadBundleFile(fullName, reader);
|
LoadBundleFile(reader);
|
||||||
break;
|
break;
|
||||||
case FileType.WebFile:
|
case FileType.WebFile:
|
||||||
LoadWebFile(fullName, reader);
|
LoadWebFile(reader);
|
||||||
|
break;
|
||||||
|
case FileType.GZipFile:
|
||||||
|
LoadFile(DecompressGZip(reader));
|
||||||
|
break;
|
||||||
|
case FileType.BrotliFile:
|
||||||
|
LoadFile(DecompressBrotli(reader));
|
||||||
|
break;
|
||||||
|
case FileType.ZipFile:
|
||||||
|
LoadZipFile(reader);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadAssetsFile(string fullName, EndianBinaryReader reader)
|
private void LoadAssetsFile(FileReader reader)
|
||||||
{
|
{
|
||||||
var fileName = Path.GetFileName(fullName);
|
if (!assetsFileListHash.Contains(reader.FileName))
|
||||||
if (!assetsFileListHash.Contains(fileName))
|
|
||||||
{
|
{
|
||||||
Logger.Info($"Loading {fileName}");
|
Logger.Info($"Loading {reader.FullPath}");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var assetsFile = new SerializedFile(this, fullName, reader);
|
var assetsFile = new SerializedFile(reader, this);
|
||||||
|
CheckStrippedVersion(assetsFile);
|
||||||
assetsFileList.Add(assetsFile);
|
assetsFileList.Add(assetsFile);
|
||||||
assetsFileListHash.Add(assetsFile.fileName);
|
assetsFileListHash.Add(assetsFile.fileName);
|
||||||
|
|
||||||
foreach (var sharedFile in assetsFile.m_Externals)
|
foreach (var sharedFile in assetsFile.m_Externals)
|
||||||
{
|
{
|
||||||
var sharedFilePath = Path.GetDirectoryName(fullName) + "\\" + sharedFile.fileName;
|
|
||||||
var sharedFileName = sharedFile.fileName;
|
var sharedFileName = sharedFile.fileName;
|
||||||
|
|
||||||
if (!importFilesHash.Contains(sharedFileName))
|
if (!importFilesHash.Contains(sharedFileName))
|
||||||
{
|
{
|
||||||
if (!File.Exists(sharedFilePath))
|
var sharedFilePath = Path.Combine(Path.GetDirectoryName(reader.FullPath), sharedFileName);
|
||||||
|
if (!noexistFiles.Contains(sharedFilePath))
|
||||||
{
|
{
|
||||||
var findFiles = Directory.GetFiles(Path.GetDirectoryName(fullName), sharedFileName, SearchOption.AllDirectories);
|
if (!File.Exists(sharedFilePath))
|
||||||
if (findFiles.Length > 0)
|
|
||||||
{
|
{
|
||||||
sharedFilePath = findFiles[0];
|
var findFiles = Directory.GetFiles(Path.GetDirectoryName(reader.FullPath), sharedFileName, SearchOption.AllDirectories);
|
||||||
|
if (findFiles.Length > 0)
|
||||||
|
{
|
||||||
|
sharedFilePath = findFiles[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (File.Exists(sharedFilePath))
|
||||||
|
{
|
||||||
|
importFiles.Add(sharedFilePath);
|
||||||
|
importFilesHash.Add(sharedFileName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
noexistFiles.Add(sharedFilePath);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (File.Exists(sharedFilePath))
|
|
||||||
{
|
|
||||||
importFiles.Add(sharedFilePath);
|
|
||||||
importFilesHash.Add(sharedFileName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch (NotSupportedException e)
|
||||||
{
|
{
|
||||||
|
Logger.Error(e.Message);
|
||||||
|
reader.Dispose();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Logger.Warning($"Error while reading assets file {reader.FullPath}\r\n{e}");
|
||||||
reader.Dispose();
|
reader.Dispose();
|
||||||
//Logger.Warning($"Unable to load assets file {fileName}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Logger.Info($"Skipping {reader.FullPath}");
|
||||||
reader.Dispose();
|
reader.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadAssetsFromMemory(string fullName, EndianBinaryReader reader, string originalPath, string unityVersion = null)
|
private void LoadAssetsFromMemory(FileReader reader, string originalPath, string unityVersion = null)
|
||||||
{
|
{
|
||||||
var fileName = Path.GetFileName(fullName);
|
if (!assetsFileListHash.Contains(reader.FileName))
|
||||||
if (!assetsFileListHash.Contains(fileName))
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var assetsFile = new SerializedFile(this, fullName, reader);
|
var assetsFile = new SerializedFile(reader, this);
|
||||||
assetsFile.originalPath = originalPath;
|
assetsFile.originalPath = originalPath;
|
||||||
if (assetsFile.header.m_Version < 7)
|
if (!string.IsNullOrEmpty(unityVersion) && assetsFile.header.m_Version < SerializedFileFormatVersion.Unknown_7)
|
||||||
{
|
{
|
||||||
assetsFile.SetVersion(unityVersion);
|
assetsFile.SetVersion(unityVersion);
|
||||||
}
|
}
|
||||||
|
CheckStrippedVersion(assetsFile);
|
||||||
assetsFileList.Add(assetsFile);
|
assetsFileList.Add(assetsFile);
|
||||||
assetsFileListHash.Add(assetsFile.fileName);
|
assetsFileListHash.Add(assetsFile.fileName);
|
||||||
}
|
}
|
||||||
catch
|
catch (NotSupportedException e)
|
||||||
{
|
{
|
||||||
//Logger.Error($"Unable to load assets file {fileName} from {Path.GetFileName(originalPath)}");
|
Logger.Error(e.Message);
|
||||||
resourceFileReaders.Add(fileName, reader);
|
resourceFileReaders.Add(reader.FileName, reader);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Logger.Warning($"Error while reading assets file {reader.FullPath} from {Path.GetFileName(originalPath)}\r\n{e}");
|
||||||
|
resourceFileReaders.Add(reader.FileName, reader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
Logger.Info($"Skipping {originalPath} ({reader.FileName})");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadBundleFile(string fullName, EndianBinaryReader reader, string parentPath = null)
|
private void LoadBundleFile(FileReader reader, string originalPath = null)
|
||||||
{
|
{
|
||||||
var fileName = Path.GetFileName(fullName);
|
Logger.Info("Loading " + reader.FullPath);
|
||||||
Logger.Info("Loading " + fileName);
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var bundleFile = new BundleFile(reader, fullName);
|
var bundleFile = new BundleFile(reader, SpecifyUnityVersion);
|
||||||
foreach (var file in bundleFile.fileList)
|
foreach (var file in bundleFile.fileList)
|
||||||
{
|
{
|
||||||
var subReader = new EndianBinaryReader(file.stream);
|
var dummyPath = Path.Combine(Path.GetDirectoryName(reader.FullPath), file.fileName);
|
||||||
if (SerializedFile.IsSerializedFile(subReader))
|
var subReader = new FileReader(dummyPath, file.stream);
|
||||||
|
if (subReader.FileType == FileType.AssetsFile)
|
||||||
{
|
{
|
||||||
var dummyPath = Path.GetDirectoryName(fullName) + Path.DirectorySeparatorChar + file.fileName;
|
LoadAssetsFromMemory(subReader, originalPath ?? reader.FullPath, bundleFile.m_Header.unityRevision);
|
||||||
LoadAssetsFromMemory(dummyPath, subReader, parentPath ?? fullName, bundleFile.m_Header.unityRevision);
|
|
||||||
}
|
}
|
||||||
else
|
else if (!resourceFileReaders.ContainsKey(file.fileName))
|
||||||
{
|
{
|
||||||
resourceFileReaders.Add(file.fileName, subReader);
|
resourceFileReaders.Add(file.fileName, subReader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch (NotSupportedException e)
|
||||||
{
|
{
|
||||||
/*var str = $"Unable to load bundle file {fileName}";
|
Logger.Error(e.Message);
|
||||||
if (parentPath != null)
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
var str = $"Error while reading bundle file {reader.FullPath}";
|
||||||
|
if (originalPath != null)
|
||||||
{
|
{
|
||||||
str += $" from {Path.GetFileName(parentPath)}";
|
str += $" from {Path.GetFileName(originalPath)}";
|
||||||
}
|
}
|
||||||
Logger.Error(str);*/
|
Logger.Warning($"{str}\r\n{e}");
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -180,36 +292,36 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadWebFile(string fullName, EndianBinaryReader reader)
|
private void LoadWebFile(FileReader reader)
|
||||||
{
|
{
|
||||||
var fileName = Path.GetFileName(fullName);
|
Logger.Info("Loading " + reader.FullPath);
|
||||||
Logger.Info("Loading " + fileName);
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var webFile = new WebFile(reader);
|
var webFile = new WebFile(reader);
|
||||||
foreach (var file in webFile.fileList)
|
foreach (var file in webFile.fileList)
|
||||||
{
|
{
|
||||||
var dummyPath = Path.GetDirectoryName(fullName) + "\\" + file.fileName;
|
var dummyPath = Path.Combine(Path.GetDirectoryName(reader.FullPath), file.fileName);
|
||||||
switch (CheckFileType(file.stream, out var fileReader))
|
var subReader = new FileReader(dummyPath, file.stream);
|
||||||
|
switch (subReader.FileType)
|
||||||
{
|
{
|
||||||
case FileType.AssetsFile:
|
case FileType.AssetsFile:
|
||||||
LoadAssetsFromMemory(dummyPath, fileReader, fullName);
|
LoadAssetsFromMemory(subReader, reader.FullPath);
|
||||||
break;
|
break;
|
||||||
case FileType.BundleFile:
|
case FileType.BundleFile:
|
||||||
LoadBundleFile(dummyPath, fileReader, fullName);
|
LoadBundleFile(subReader, reader.FullPath);
|
||||||
break;
|
break;
|
||||||
case FileType.WebFile:
|
case FileType.WebFile:
|
||||||
LoadWebFile(dummyPath, fileReader);
|
LoadWebFile(subReader);
|
||||||
break;
|
break;
|
||||||
case FileType.ResourceFile:
|
case FileType.ResourceFile:
|
||||||
resourceFileReaders.Add(file.fileName, fileReader);
|
resourceFileReaders[file.fileName] = subReader; //TODO
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
//Logger.Error($"Unable to load web file {fileName}");
|
Logger.Error($"Error while reading web file {reader.FullPath}", e);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -217,6 +329,122 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LoadZipFile(FileReader reader)
|
||||||
|
{
|
||||||
|
Logger.Info("Reading " + reader.FileName);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (ZipArchive archive = new ZipArchive(reader.BaseStream, ZipArchiveMode.Read))
|
||||||
|
{
|
||||||
|
List<string> splitFiles = new List<string>();
|
||||||
|
// register all files before parsing the assets so that the external references can be found
|
||||||
|
// and find split files
|
||||||
|
foreach (ZipArchiveEntry entry in archive.Entries)
|
||||||
|
{
|
||||||
|
if (entry.Name.Contains(".split"))
|
||||||
|
{
|
||||||
|
string baseName = Path.GetFileNameWithoutExtension(entry.Name);
|
||||||
|
string basePath = Path.Combine(Path.GetDirectoryName(entry.FullName), baseName);
|
||||||
|
if (!splitFiles.Contains(basePath))
|
||||||
|
{
|
||||||
|
splitFiles.Add(basePath);
|
||||||
|
importFilesHash.Add(baseName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
importFilesHash.Add(entry.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// merge split files and load the result
|
||||||
|
foreach (string basePath in splitFiles)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Stream splitStream = new MemoryStream();
|
||||||
|
int i = 0;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
string path = $"{basePath}.split{i++}";
|
||||||
|
ZipArchiveEntry entry = archive.GetEntry(path);
|
||||||
|
if (entry == null)
|
||||||
|
break;
|
||||||
|
using (Stream entryStream = entry.Open())
|
||||||
|
{
|
||||||
|
entryStream.CopyTo(splitStream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
splitStream.Seek(0, SeekOrigin.Begin);
|
||||||
|
FileReader entryReader = new FileReader(basePath, splitStream);
|
||||||
|
LoadFile(entryReader);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Logger.Warning($"Error while reading zip split file {basePath}\r\n{e}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// load all entries
|
||||||
|
var progressCount = archive.Entries.Count;
|
||||||
|
int k = 0;
|
||||||
|
Progress.Reset();
|
||||||
|
foreach (ZipArchiveEntry entry in archive.Entries)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string dummyPath = Path.Combine(Path.GetDirectoryName(reader.FullPath), reader.FileName, entry.FullName);
|
||||||
|
// create a new stream
|
||||||
|
// - to store the deflated stream in
|
||||||
|
// - to keep the data for later extraction
|
||||||
|
Stream streamReader = new MemoryStream();
|
||||||
|
using (Stream entryStream = entry.Open())
|
||||||
|
{
|
||||||
|
entryStream.CopyTo(streamReader);
|
||||||
|
}
|
||||||
|
streamReader.Position = 0;
|
||||||
|
|
||||||
|
FileReader entryReader = new FileReader(dummyPath, streamReader);
|
||||||
|
LoadFile(entryReader);
|
||||||
|
if (entryReader.FileType == FileType.ResourceFile)
|
||||||
|
{
|
||||||
|
entryReader.Position = 0;
|
||||||
|
if (!resourceFileReaders.ContainsKey(entry.Name))
|
||||||
|
{
|
||||||
|
resourceFileReaders.Add(entry.Name, entryReader);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Progress.Report(++k, progressCount);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Logger.Warning($"Error while reading zip entry {entry.FullName}\r\n{e}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Logger.Error($"Error while reading zip file {reader.FileName}", e);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
reader.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CheckStrippedVersion(SerializedFile assetsFile)
|
||||||
|
{
|
||||||
|
if (assetsFile.IsVersionStripped && string.IsNullOrEmpty(SpecifyUnityVersion))
|
||||||
|
{
|
||||||
|
throw new NotSupportedException("The Unity version has been stripped, please set the version in the options");
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(SpecifyUnityVersion))
|
||||||
|
{
|
||||||
|
assetsFile.SetVersion(SpecifyUnityVersion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Clear()
|
public void Clear()
|
||||||
{
|
{
|
||||||
foreach (var assetsFile in assetsFileList)
|
foreach (var assetsFile in assetsFileList)
|
||||||
@@ -247,9 +475,13 @@ namespace AssetStudio
|
|||||||
foreach (var objectInfo in assetsFile.m_Objects)
|
foreach (var objectInfo in assetsFile.m_Objects)
|
||||||
{
|
{
|
||||||
var objectReader = new ObjectReader(assetsFile.reader, assetsFile, objectInfo);
|
var objectReader = new ObjectReader(assetsFile.reader, assetsFile, objectInfo);
|
||||||
|
if (filteredAssetTypesList.Count > 0 && !filteredAssetTypesList.Contains(objectReader.type))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Object obj;
|
Object obj = null;
|
||||||
switch (objectReader.type)
|
switch (objectReader.type)
|
||||||
{
|
{
|
||||||
case ClassIDType.Animation:
|
case ClassIDType.Animation:
|
||||||
@@ -306,11 +538,15 @@ namespace AssetStudio
|
|||||||
case ClassIDType.PlayerSettings:
|
case ClassIDType.PlayerSettings:
|
||||||
obj = new PlayerSettings(objectReader);
|
obj = new PlayerSettings(objectReader);
|
||||||
break;
|
break;
|
||||||
|
case ClassIDType.PreloadData:
|
||||||
|
obj = new PreloadData(objectReader);
|
||||||
|
break;
|
||||||
case ClassIDType.RectTransform:
|
case ClassIDType.RectTransform:
|
||||||
obj = new RectTransform(objectReader);
|
obj = new RectTransform(objectReader);
|
||||||
break;
|
break;
|
||||||
case ClassIDType.Shader:
|
case ClassIDType.Shader:
|
||||||
obj = new Shader(objectReader);
|
if (objectReader.version[0] < 2021)
|
||||||
|
obj = new Shader(objectReader);
|
||||||
break;
|
break;
|
||||||
case ClassIDType.SkinnedMeshRenderer:
|
case ClassIDType.SkinnedMeshRenderer:
|
||||||
obj = new SkinnedMeshRenderer(objectReader);
|
obj = new SkinnedMeshRenderer(objectReader);
|
||||||
@@ -333,21 +569,26 @@ namespace AssetStudio
|
|||||||
case ClassIDType.VideoClip:
|
case ClassIDType.VideoClip:
|
||||||
obj = new VideoClip(objectReader);
|
obj = new VideoClip(objectReader);
|
||||||
break;
|
break;
|
||||||
|
case ClassIDType.ResourceManager:
|
||||||
|
obj = new ResourceManager(objectReader);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
obj = new Object(objectReader);
|
obj = new Object(objectReader);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
assetsFile.AddObject(obj);
|
if (obj != null)
|
||||||
|
assetsFile.AddObject(obj);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
/*var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
sb.AppendLine("Unable to load object")
|
sb.AppendLine("Unable to load object")
|
||||||
.AppendLine($"Assets {assetsFile.fileName}")
|
.AppendLine($"Assets {assetsFile.fileName}")
|
||||||
|
.AppendLine($"Path {assetsFile.originalPath}")
|
||||||
.AppendLine($"Type {objectReader.type}")
|
.AppendLine($"Type {objectReader.type}")
|
||||||
.AppendLine($"PathID {objectInfo.m_PathID}")
|
.AppendLine($"PathID {objectInfo.m_PathID}")
|
||||||
.Append(e);
|
.Append(e);
|
||||||
Logger.Error(sb.ToString());*/
|
Logger.Warning(sb.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
Progress.Report(++i, progressCount);
|
Progress.Report(++i, progressCount);
|
||||||
@@ -357,7 +598,7 @@ namespace AssetStudio
|
|||||||
|
|
||||||
private void ProcessAssets()
|
private void ProcessAssets()
|
||||||
{
|
{
|
||||||
Logger.Info("Process Assets...");
|
Logger.Info("Process assets...");
|
||||||
|
|
||||||
foreach (var assetsFile in assetsFileList)
|
foreach (var assetsFile in assetsFileList)
|
||||||
{
|
{
|
||||||
@@ -403,6 +644,17 @@ namespace AssetStudio
|
|||||||
{
|
{
|
||||||
m_Sprite.m_SpriteAtlas.Set(m_SpriteAtlas);
|
m_Sprite.m_SpriteAtlas.Set(m_SpriteAtlas);
|
||||||
}
|
}
|
||||||
|
else if (m_Sprite.m_SpriteAtlas.TryGet(out var m_SpriteAtlaOld))
|
||||||
|
{
|
||||||
|
if (m_SpriteAtlaOld.m_IsVariant)
|
||||||
|
{
|
||||||
|
m_Sprite.m_SpriteAtlas.Set(m_SpriteAtlas);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.Warning($"\"{m_Sprite.m_Name}\": Sprite loading error. SpriteAtlas with PathID: \"{m_Sprite.m_SpriteAtlas.m_PathID}\" was not found.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
10
AssetStudio/BigArrayPool.cs
Normal file
10
AssetStudio/BigArrayPool.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using System.Buffers;
|
||||||
|
|
||||||
|
namespace AssetStudio
|
||||||
|
{
|
||||||
|
public static class BigArrayPool<T>
|
||||||
|
{
|
||||||
|
private static readonly ArrayPool<T> s_shared = ArrayPool<T>.Create(64 * 1024 * 1024, 3);
|
||||||
|
public static ArrayPool<T> Shared => s_shared;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,8 +7,9 @@ namespace AssetStudio
|
|||||||
{
|
{
|
||||||
public enum BuildTarget
|
public enum BuildTarget
|
||||||
{
|
{
|
||||||
UnknownPlatform = 3716,
|
NoTarget = -2,
|
||||||
DashboardWidget = 1,
|
AnyPlayer = -1,
|
||||||
|
ValidPlayer = 1,
|
||||||
StandaloneOSX = 2,
|
StandaloneOSX = 2,
|
||||||
StandaloneOSXPPC = 3,
|
StandaloneOSXPPC = 3,
|
||||||
StandaloneOSXIntel = 4,
|
StandaloneOSXIntel = 4,
|
||||||
@@ -19,8 +20,10 @@ namespace AssetStudio
|
|||||||
iOS = 9,
|
iOS = 9,
|
||||||
PS3,
|
PS3,
|
||||||
XBOX360,
|
XBOX360,
|
||||||
|
Broadcom = 12,
|
||||||
Android = 13,
|
Android = 13,
|
||||||
StandaloneGLESEmu = 14,
|
StandaloneGLESEmu = 14,
|
||||||
|
StandaloneGLES20Emu = 15,
|
||||||
NaCl = 16,
|
NaCl = 16,
|
||||||
StandaloneLinux = 17,
|
StandaloneLinux = 17,
|
||||||
FlashPlayer = 18,
|
FlashPlayer = 18,
|
||||||
@@ -42,6 +45,14 @@ namespace AssetStudio
|
|||||||
WiiU,
|
WiiU,
|
||||||
tvOS,
|
tvOS,
|
||||||
Switch,
|
Switch,
|
||||||
NoTarget = -2
|
Lumin,
|
||||||
|
Stadia,
|
||||||
|
CloudRendering,
|
||||||
|
GameCoreXboxSeries,
|
||||||
|
GameCoreXboxOne,
|
||||||
|
PS5,
|
||||||
|
EmbeddedLinux,
|
||||||
|
QNX,
|
||||||
|
UnknownPlatform = 9999
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,43 @@
|
|||||||
using System;
|
using K4os.Compression.LZ4;
|
||||||
using System.Collections.Generic;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Lz4;
|
|
||||||
|
|
||||||
namespace AssetStudio
|
namespace AssetStudio
|
||||||
{
|
{
|
||||||
|
[Flags]
|
||||||
|
public enum ArchiveFlags
|
||||||
|
{
|
||||||
|
CompressionTypeMask = 0x3f,
|
||||||
|
BlocksAndDirectoryInfoCombined = 0x40,
|
||||||
|
BlocksInfoAtTheEnd = 0x80,
|
||||||
|
OldWebPluginCompatibility = 0x100,
|
||||||
|
BlockInfoNeedPaddingAtStart = 0x200
|
||||||
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum CnEncryptionFlags
|
||||||
|
{
|
||||||
|
OldFlag = 0x200,
|
||||||
|
NewFlag = 0x400
|
||||||
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum StorageBlockFlags
|
||||||
|
{
|
||||||
|
CompressionTypeMask = 0x3f,
|
||||||
|
Streamed = 0x40
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum CompressionType
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
Lzma,
|
||||||
|
Lz4,
|
||||||
|
Lz4HC,
|
||||||
|
Lzham
|
||||||
|
}
|
||||||
|
|
||||||
public class BundleFile
|
public class BundleFile
|
||||||
{
|
{
|
||||||
public class Header
|
public class Header
|
||||||
@@ -17,14 +49,14 @@ namespace AssetStudio
|
|||||||
public long size;
|
public long size;
|
||||||
public uint compressedBlocksInfoSize;
|
public uint compressedBlocksInfoSize;
|
||||||
public uint uncompressedBlocksInfoSize;
|
public uint uncompressedBlocksInfoSize;
|
||||||
public uint flags;
|
public ArchiveFlags flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class StorageBlock
|
public class StorageBlock
|
||||||
{
|
{
|
||||||
public uint compressedSize;
|
public uint compressedSize;
|
||||||
public uint uncompressedSize;
|
public uint uncompressedSize;
|
||||||
public ushort flags;
|
public StorageBlockFlags flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Node
|
public class Node
|
||||||
@@ -41,30 +73,61 @@ namespace AssetStudio
|
|||||||
|
|
||||||
public StreamFile[] fileList;
|
public StreamFile[] fileList;
|
||||||
|
|
||||||
public BundleFile(EndianBinaryReader reader, string path)
|
public BundleFile(FileReader reader, string specUnityVer = "")
|
||||||
{
|
{
|
||||||
m_Header = new Header();
|
m_Header = new Header();
|
||||||
m_Header.signature = reader.ReadStringToNull();
|
m_Header.signature = reader.ReadStringToNull();
|
||||||
|
m_Header.version = reader.ReadUInt32();
|
||||||
|
m_Header.unityVersion = reader.ReadStringToNull();
|
||||||
|
m_Header.unityRevision = reader.ReadStringToNull();
|
||||||
switch (m_Header.signature)
|
switch (m_Header.signature)
|
||||||
{
|
{
|
||||||
case "UnityArchive":
|
case "UnityArchive":
|
||||||
break; //TODO
|
break; //TODO
|
||||||
case "UnityWeb":
|
case "UnityWeb":
|
||||||
case "UnityRaw":
|
case "UnityRaw":
|
||||||
|
if (m_Header.version == 6)
|
||||||
|
{
|
||||||
|
goto case "UnityFS";
|
||||||
|
}
|
||||||
ReadHeaderAndBlocksInfo(reader);
|
ReadHeaderAndBlocksInfo(reader);
|
||||||
using (var blocksStream = CreateBlocksStream(path))
|
using (var blocksStream = CreateBlocksStream(reader.FullPath))
|
||||||
{
|
{
|
||||||
ReadBlocksAndDirectory(reader, blocksStream);
|
ReadBlocksAndDirectory(reader, blocksStream);
|
||||||
ReadFiles(blocksStream, path);
|
ReadFiles(blocksStream, reader.FullPath);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "UnityFS":
|
case "UnityFS":
|
||||||
ReadHeader(reader);
|
ReadHeader(reader);
|
||||||
ReadBlocksInfoAndDirectory(reader);
|
|
||||||
using (var blocksStream = CreateBlocksStream(path))
|
bool isUnityCnEnc = false;
|
||||||
|
string unityVer = string.IsNullOrEmpty(specUnityVer) ? m_Header.unityRevision : specUnityVer;
|
||||||
|
int[] ver = new string(unityVer.SkipWhile(x => !char.IsDigit(x)).TakeWhile(x => char.IsDigit(x) || x == '.').ToArray()).Split('.').Select(x => int.Parse(x)).ToArray();
|
||||||
|
if (ver[0] != 0)
|
||||||
|
{
|
||||||
|
// https://issuetracker.unity3d.com/issues/files-within-assetbundles-do-not-start-on-aligned-boundaries-breaking-patching-on-nintendo-switch
|
||||||
|
if (ver[0] < 2020 ||
|
||||||
|
(ver[0] == 2020 && ver[1] <= 3 && ver[2] < 34) ||
|
||||||
|
(ver[0] == 2021 && ver[1] <= 3 && ver[2] < 2) ||
|
||||||
|
(ver[0] == 2022 && ver[1] <= 1 && ver[2] < 1))
|
||||||
|
{
|
||||||
|
isUnityCnEnc = ((CnEncryptionFlags)m_Header.flags & CnEncryptionFlags.OldFlag) != 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
isUnityCnEnc = ((CnEncryptionFlags)m_Header.flags & CnEncryptionFlags.NewFlag) != 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isUnityCnEnc)
|
||||||
|
{
|
||||||
|
throw new NotSupportedException("Unsupported bundle file. UnityCN encryption was detected.");
|
||||||
|
}
|
||||||
|
|
||||||
|
ReadBlocksInfoAndDirectory(reader, ver);
|
||||||
|
using (var blocksStream = CreateBlocksStream(reader.FullPath))
|
||||||
{
|
{
|
||||||
ReadBlocks(reader, blocksStream);
|
ReadBlocks(reader, blocksStream);
|
||||||
ReadFiles(blocksStream, path);
|
ReadFiles(blocksStream, reader.FullPath);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -72,17 +135,13 @@ namespace AssetStudio
|
|||||||
|
|
||||||
private void ReadHeaderAndBlocksInfo(EndianBinaryReader reader)
|
private void ReadHeaderAndBlocksInfo(EndianBinaryReader reader)
|
||||||
{
|
{
|
||||||
var isCompressed = m_Header.signature == "UnityWeb";
|
|
||||||
m_Header.version = reader.ReadUInt32();
|
|
||||||
m_Header.unityVersion = reader.ReadStringToNull();
|
|
||||||
m_Header.unityRevision = reader.ReadStringToNull();
|
|
||||||
if (m_Header.version >= 4)
|
if (m_Header.version >= 4)
|
||||||
{
|
{
|
||||||
var hash = reader.ReadBytes(16);
|
var hash = reader.ReadBytes(16);
|
||||||
var crc = reader.ReadUInt32();
|
var crc = reader.ReadUInt32();
|
||||||
}
|
}
|
||||||
var minimumStreamedBytes = reader.ReadUInt32();
|
var minimumStreamedBytes = reader.ReadUInt32();
|
||||||
var headerSize = reader.ReadUInt32();
|
m_Header.size = reader.ReadUInt32();
|
||||||
var numberOfLevelsToDownloadBeforeStreaming = reader.ReadUInt32();
|
var numberOfLevelsToDownloadBeforeStreaming = reader.ReadUInt32();
|
||||||
var levelCount = reader.ReadInt32();
|
var levelCount = reader.ReadInt32();
|
||||||
m_BlocksInfo = new StorageBlock[1];
|
m_BlocksInfo = new StorageBlock[1];
|
||||||
@@ -92,7 +151,6 @@ namespace AssetStudio
|
|||||||
{
|
{
|
||||||
compressedSize = reader.ReadUInt32(),
|
compressedSize = reader.ReadUInt32(),
|
||||||
uncompressedSize = reader.ReadUInt32(),
|
uncompressedSize = reader.ReadUInt32(),
|
||||||
flags = (ushort)(isCompressed ? 1 : 0)
|
|
||||||
};
|
};
|
||||||
if (i == levelCount - 1)
|
if (i == levelCount - 1)
|
||||||
{
|
{
|
||||||
@@ -107,7 +165,7 @@ namespace AssetStudio
|
|||||||
{
|
{
|
||||||
var fileInfoHeaderSize = reader.ReadUInt32();
|
var fileInfoHeaderSize = reader.ReadUInt32();
|
||||||
}
|
}
|
||||||
reader.Position = headerSize;
|
reader.Position = m_Header.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Stream CreateBlocksStream(string path)
|
private Stream CreateBlocksStream(string path)
|
||||||
@@ -116,7 +174,7 @@ namespace AssetStudio
|
|||||||
var uncompressedSizeSum = m_BlocksInfo.Sum(x => x.uncompressedSize);
|
var uncompressedSizeSum = m_BlocksInfo.Sum(x => x.uncompressedSize);
|
||||||
if (uncompressedSizeSum >= int.MaxValue)
|
if (uncompressedSizeSum >= int.MaxValue)
|
||||||
{
|
{
|
||||||
/*var memoryMappedFile = MemoryMappedFile.CreateNew(Path.GetFileName(path), uncompressedSizeSum);
|
/*var memoryMappedFile = MemoryMappedFile.CreateNew(null, uncompressedSizeSum);
|
||||||
assetsDataStream = memoryMappedFile.CreateViewStream();*/
|
assetsDataStream = memoryMappedFile.CreateViewStream();*/
|
||||||
blocksStream = new FileStream(path + ".temp", FileMode.Create, FileAccess.ReadWrite, FileShare.None, 4096, FileOptions.DeleteOnClose);
|
blocksStream = new FileStream(path + ".temp", FileMode.Create, FileAccess.ReadWrite, FileShare.None, 4096, FileOptions.DeleteOnClose);
|
||||||
}
|
}
|
||||||
@@ -129,10 +187,11 @@ namespace AssetStudio
|
|||||||
|
|
||||||
private void ReadBlocksAndDirectory(EndianBinaryReader reader, Stream blocksStream)
|
private void ReadBlocksAndDirectory(EndianBinaryReader reader, Stream blocksStream)
|
||||||
{
|
{
|
||||||
|
var isCompressed = m_Header.signature == "UnityWeb";
|
||||||
foreach (var blockInfo in m_BlocksInfo)
|
foreach (var blockInfo in m_BlocksInfo)
|
||||||
{
|
{
|
||||||
var uncompressedBytes = reader.ReadBytes((int)blockInfo.compressedSize);
|
var uncompressedBytes = reader.ReadBytes((int)blockInfo.compressedSize);
|
||||||
if (blockInfo.flags == 1)
|
if (isCompressed)
|
||||||
{
|
{
|
||||||
using (var memoryStream = new MemoryStream(uncompressedBytes))
|
using (var memoryStream = new MemoryStream(uncompressedBytes))
|
||||||
{
|
{
|
||||||
@@ -167,14 +226,15 @@ namespace AssetStudio
|
|||||||
var node = m_DirectoryInfo[i];
|
var node = m_DirectoryInfo[i];
|
||||||
var file = new StreamFile();
|
var file = new StreamFile();
|
||||||
fileList[i] = file;
|
fileList[i] = file;
|
||||||
|
file.path = node.path;
|
||||||
file.fileName = Path.GetFileName(node.path);
|
file.fileName = Path.GetFileName(node.path);
|
||||||
if (node.size >= int.MaxValue)
|
if (node.size >= int.MaxValue)
|
||||||
{
|
{
|
||||||
/*var memoryMappedFile = MemoryMappedFile.CreateNew(file.fileName, entryinfo_size);
|
/*var memoryMappedFile = MemoryMappedFile.CreateNew(null, entryinfo_size);
|
||||||
file.stream = memoryMappedFile.CreateViewStream();*/
|
file.stream = memoryMappedFile.CreateViewStream();*/
|
||||||
var extractPath = path + "_unpacked" + Path.DirectorySeparatorChar;
|
var extractPath = path + "_unpacked" + Path.DirectorySeparatorChar;
|
||||||
Directory.CreateDirectory(extractPath);
|
Directory.CreateDirectory(extractPath);
|
||||||
file.stream = File.Create(extractPath + file.fileName);
|
file.stream = new FileStream(extractPath + file.fileName, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -188,59 +248,82 @@ namespace AssetStudio
|
|||||||
|
|
||||||
private void ReadHeader(EndianBinaryReader reader)
|
private void ReadHeader(EndianBinaryReader reader)
|
||||||
{
|
{
|
||||||
m_Header.version = reader.ReadUInt32();
|
|
||||||
m_Header.unityVersion = reader.ReadStringToNull();
|
|
||||||
m_Header.unityRevision = reader.ReadStringToNull();
|
|
||||||
m_Header.size = reader.ReadInt64();
|
m_Header.size = reader.ReadInt64();
|
||||||
m_Header.compressedBlocksInfoSize = reader.ReadUInt32();
|
m_Header.compressedBlocksInfoSize = reader.ReadUInt32();
|
||||||
m_Header.uncompressedBlocksInfoSize = reader.ReadUInt32();
|
m_Header.uncompressedBlocksInfoSize = reader.ReadUInt32();
|
||||||
m_Header.flags = reader.ReadUInt32();
|
m_Header.flags = (ArchiveFlags)reader.ReadUInt32();
|
||||||
|
if (m_Header.signature != "UnityFS")
|
||||||
|
{
|
||||||
|
reader.ReadByte();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReadBlocksInfoAndDirectory(EndianBinaryReader reader)
|
private void ReadBlocksInfoAndDirectory(EndianBinaryReader reader, int[] unityVer)
|
||||||
{
|
{
|
||||||
byte[] blocksInfoBytes;
|
byte[] blocksInfoBytes;
|
||||||
if ((m_Header.flags & 0x80) != 0) //kArchiveBlocksInfoAtTheEnd
|
|
||||||
|
if (m_Header.version >= 7)
|
||||||
|
{
|
||||||
|
reader.AlignStream(16);
|
||||||
|
}
|
||||||
|
else if (unityVer[0] >= 2019 && unityVer[1] >= 4)
|
||||||
|
{
|
||||||
|
//check if we need to align the reader
|
||||||
|
//- align to 16 bytes and check if all are 0
|
||||||
|
//- if not, reset the reader to the previous position
|
||||||
|
var preAlign = reader.Position;
|
||||||
|
var alignData = reader.ReadBytes((16 - (int)(preAlign % 16)) % 16);
|
||||||
|
if (alignData.Any(x => x != 0))
|
||||||
|
{
|
||||||
|
reader.Position = preAlign;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((m_Header.flags & ArchiveFlags.BlocksInfoAtTheEnd) != 0)
|
||||||
{
|
{
|
||||||
var position = reader.Position;
|
var position = reader.Position;
|
||||||
reader.Position = reader.BaseStream.Length - m_Header.compressedBlocksInfoSize;
|
reader.Position = reader.BaseStream.Length - m_Header.compressedBlocksInfoSize;
|
||||||
blocksInfoBytes = reader.ReadBytes((int)m_Header.compressedBlocksInfoSize);
|
blocksInfoBytes = reader.ReadBytes((int)m_Header.compressedBlocksInfoSize);
|
||||||
reader.Position = position;
|
reader.Position = position;
|
||||||
}
|
}
|
||||||
else //0x40 kArchiveBlocksAndDirectoryInfoCombined
|
else //0x40 BlocksAndDirectoryInfoCombined
|
||||||
{
|
{
|
||||||
if (m_Header.version >= 7)
|
|
||||||
{
|
|
||||||
reader.AlignStream(16);
|
|
||||||
}
|
|
||||||
blocksInfoBytes = reader.ReadBytes((int)m_Header.compressedBlocksInfoSize);
|
blocksInfoBytes = reader.ReadBytes((int)m_Header.compressedBlocksInfoSize);
|
||||||
}
|
}
|
||||||
var blocksInfoCompressedStream = new MemoryStream(blocksInfoBytes);
|
|
||||||
MemoryStream blocksInfoUncompresseddStream;
|
MemoryStream blocksInfoUncompresseddStream;
|
||||||
switch (m_Header.flags & 0x3F) //kArchiveCompressionTypeMask
|
var uncompressedSize = m_Header.uncompressedBlocksInfoSize;
|
||||||
|
var compressionType = (CompressionType)(m_Header.flags & ArchiveFlags.CompressionTypeMask);
|
||||||
|
switch (compressionType)
|
||||||
{
|
{
|
||||||
default: //None
|
case CompressionType.None:
|
||||||
{
|
{
|
||||||
blocksInfoUncompresseddStream = blocksInfoCompressedStream;
|
blocksInfoUncompresseddStream = new MemoryStream(blocksInfoBytes);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1: //LZMA
|
case CompressionType.Lzma:
|
||||||
{
|
{
|
||||||
blocksInfoUncompresseddStream = SevenZipHelper.StreamDecompress(blocksInfoCompressedStream);
|
blocksInfoUncompresseddStream = new MemoryStream((int)(uncompressedSize));
|
||||||
blocksInfoCompressedStream.Close();
|
using (var blocksInfoCompressedStream = new MemoryStream(blocksInfoBytes))
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 2: //LZ4
|
|
||||||
case 3: //LZ4HC
|
|
||||||
{
|
|
||||||
var uncompressedBytes = new byte[m_Header.uncompressedBlocksInfoSize];
|
|
||||||
using (var decoder = new Lz4DecoderStream(blocksInfoCompressedStream))
|
|
||||||
{
|
{
|
||||||
decoder.Read(uncompressedBytes, 0, uncompressedBytes.Length);
|
SevenZipHelper.StreamDecompress(blocksInfoCompressedStream, blocksInfoUncompresseddStream, m_Header.compressedBlocksInfoSize, m_Header.uncompressedBlocksInfoSize);
|
||||||
|
}
|
||||||
|
blocksInfoUncompresseddStream.Position = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CompressionType.Lz4:
|
||||||
|
case CompressionType.Lz4HC:
|
||||||
|
{
|
||||||
|
var uncompressedBytes = new byte[uncompressedSize];
|
||||||
|
var numWrite = LZ4Codec.Decode(blocksInfoBytes, uncompressedBytes);
|
||||||
|
if (numWrite != uncompressedSize)
|
||||||
|
{
|
||||||
|
throw new IOException($"Lz4 decompression error, write {numWrite} bytes but expected {uncompressedSize} bytes");
|
||||||
}
|
}
|
||||||
blocksInfoUncompresseddStream = new MemoryStream(uncompressedBytes);
|
blocksInfoUncompresseddStream = new MemoryStream(uncompressedBytes);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
throw new IOException($"Unsupported compression type {compressionType}");
|
||||||
}
|
}
|
||||||
using (var blocksInfoReader = new EndianBinaryReader(blocksInfoUncompresseddStream))
|
using (var blocksInfoReader = new EndianBinaryReader(blocksInfoUncompresseddStream))
|
||||||
{
|
{
|
||||||
@@ -253,7 +336,7 @@ namespace AssetStudio
|
|||||||
{
|
{
|
||||||
uncompressedSize = blocksInfoReader.ReadUInt32(),
|
uncompressedSize = blocksInfoReader.ReadUInt32(),
|
||||||
compressedSize = blocksInfoReader.ReadUInt32(),
|
compressedSize = blocksInfoReader.ReadUInt32(),
|
||||||
flags = blocksInfoReader.ReadUInt16()
|
flags = (StorageBlockFlags)blocksInfoReader.ReadUInt16()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,34 +353,49 @@ namespace AssetStudio
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ((m_Header.flags & ArchiveFlags.BlockInfoNeedPaddingAtStart) != 0)
|
||||||
|
{
|
||||||
|
reader.AlignStream(16);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReadBlocks(EndianBinaryReader reader, Stream blocksStream)
|
private void ReadBlocks(EndianBinaryReader reader, Stream blocksStream)
|
||||||
{
|
{
|
||||||
foreach (var blockInfo in m_BlocksInfo)
|
foreach (var blockInfo in m_BlocksInfo)
|
||||||
{
|
{
|
||||||
switch (blockInfo.flags & 0x3F) //kStorageBlockCompressionTypeMask
|
var compressionType = (CompressionType)(blockInfo.flags & StorageBlockFlags.CompressionTypeMask);
|
||||||
|
switch (compressionType)
|
||||||
{
|
{
|
||||||
default: //None
|
case CompressionType.None:
|
||||||
{
|
{
|
||||||
reader.BaseStream.CopyTo(blocksStream, blockInfo.compressedSize);
|
reader.BaseStream.CopyTo(blocksStream, blockInfo.compressedSize);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1: //LZMA
|
case CompressionType.Lzma:
|
||||||
{
|
{
|
||||||
SevenZipHelper.StreamDecompress(reader.BaseStream, blocksStream, blockInfo.compressedSize, blockInfo.uncompressedSize);
|
SevenZipHelper.StreamDecompress(reader.BaseStream, blocksStream, blockInfo.compressedSize, blockInfo.uncompressedSize);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2: //LZ4
|
case CompressionType.Lz4:
|
||||||
case 3: //LZ4HC
|
case CompressionType.Lz4HC:
|
||||||
{
|
{
|
||||||
var compressedStream = new MemoryStream(reader.ReadBytes((int)blockInfo.compressedSize));
|
var compressedSize = (int)blockInfo.compressedSize;
|
||||||
using (var lz4Stream = new Lz4DecoderStream(compressedStream))
|
var compressedBytes = BigArrayPool<byte>.Shared.Rent(compressedSize);
|
||||||
|
reader.Read(compressedBytes, 0, compressedSize);
|
||||||
|
var uncompressedSize = (int)blockInfo.uncompressedSize;
|
||||||
|
var uncompressedBytes = BigArrayPool<byte>.Shared.Rent(uncompressedSize);
|
||||||
|
var numWrite = LZ4Codec.Decode(compressedBytes, 0, compressedSize, uncompressedBytes, 0, uncompressedSize);
|
||||||
|
if (numWrite != uncompressedSize)
|
||||||
{
|
{
|
||||||
lz4Stream.CopyTo(blocksStream, blockInfo.uncompressedSize);
|
throw new IOException($"Lz4 decompression error, write {numWrite} bytes but expected {uncompressedSize} bytes");
|
||||||
}
|
}
|
||||||
|
blocksStream.Write(uncompressedBytes, 0, uncompressedSize);
|
||||||
|
BigArrayPool<byte>.Shared.Return(compressedBytes);
|
||||||
|
BigArrayPool<byte>.Shared.Return(uncompressedBytes);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
throw new IOException($"Unsupported compression type {compressionType}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
blocksStream.Position = 0;
|
blocksStream.Position = 0;
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
namespace AssetStudio
|
// official Class ID Reference: https://docs.unity3d.com/Manual/ClassIDReference.html
|
||||||
|
namespace AssetStudio
|
||||||
{
|
{
|
||||||
public enum ClassIDType
|
public enum ClassIDType
|
||||||
{
|
{
|
||||||
|
AkPortraitSprite = -2,
|
||||||
UnknownType = -1,
|
UnknownType = -1,
|
||||||
Object = 0,
|
Object = 0,
|
||||||
GameObject = 1,
|
GameObject = 1,
|
||||||
@@ -26,7 +28,7 @@
|
|||||||
ParticleRenderer = 26,
|
ParticleRenderer = 26,
|
||||||
Texture = 27,
|
Texture = 27,
|
||||||
Texture2D = 28,
|
Texture2D = 28,
|
||||||
SceneSettings = 29,
|
OcclusionCullingSettings = 29,
|
||||||
GraphicsSettings = 30,
|
GraphicsSettings = 30,
|
||||||
MeshFilter = 33,
|
MeshFilter = 33,
|
||||||
OcclusionPortal = 41,
|
OcclusionPortal = 41,
|
||||||
@@ -49,7 +51,7 @@
|
|||||||
PhysicsMaterial2D = 62,
|
PhysicsMaterial2D = 62,
|
||||||
MeshCollider = 64,
|
MeshCollider = 64,
|
||||||
BoxCollider = 65,
|
BoxCollider = 65,
|
||||||
SpriteCollider2D = 66,
|
CompositeCollider2D = 66,
|
||||||
EdgeCollider2D = 68,
|
EdgeCollider2D = 68,
|
||||||
CapsuleCollider2D = 70,
|
CapsuleCollider2D = 70,
|
||||||
ComputeShader = 72,
|
ComputeShader = 72,
|
||||||
@@ -92,6 +94,7 @@
|
|||||||
FlareLayer = 124,
|
FlareLayer = 124,
|
||||||
HaloLayer = 125,
|
HaloLayer = 125,
|
||||||
NavMeshAreas = 126,
|
NavMeshAreas = 126,
|
||||||
|
NavMeshProjectSettings = 126,
|
||||||
HaloManager = 127,
|
HaloManager = 127,
|
||||||
Font = 128,
|
Font = 128,
|
||||||
PlayerSettings = 129,
|
PlayerSettings = 129,
|
||||||
@@ -158,7 +161,7 @@
|
|||||||
BlendTree = 206,
|
BlendTree = 206,
|
||||||
Motion = 207,
|
Motion = 207,
|
||||||
NavMeshObstacle = 208,
|
NavMeshObstacle = 208,
|
||||||
TerrainInstance = 210,
|
SortingGroup = 210,
|
||||||
SpriteRenderer = 212,
|
SpriteRenderer = 212,
|
||||||
Sprite = 213,
|
Sprite = 213,
|
||||||
CachedSpriteAtlas = 214,
|
CachedSpriteAtlas = 214,
|
||||||
@@ -216,15 +219,19 @@
|
|||||||
PerformanceReportingManager = 305,
|
PerformanceReportingManager = 305,
|
||||||
UnityConnectSettings = 310,
|
UnityConnectSettings = 310,
|
||||||
AvatarMask = 319,
|
AvatarMask = 319,
|
||||||
|
PlayableDirector = 320,
|
||||||
VideoPlayer = 328,
|
VideoPlayer = 328,
|
||||||
VideoClip = 329,
|
VideoClip = 329,
|
||||||
|
ParticleSystemForceField = 330,
|
||||||
|
SpriteMask = 331,
|
||||||
|
WorldAnchor = 362,
|
||||||
OcclusionCullingData = 363,
|
OcclusionCullingData = 363,
|
||||||
//kLargestRuntimeClassID = 364
|
//kLargestRuntimeClassID = 364
|
||||||
SmallestEditorClassID = 1000,
|
SmallestEditorClassID = 1000,
|
||||||
Prefab = 1001,
|
PrefabInstance = 1001,
|
||||||
EditorExtensionImpl = 1002,
|
EditorExtensionImpl = 1002,
|
||||||
AssetImporter = 1003,
|
AssetImporter = 1003,
|
||||||
AssetDatabase = 1004,
|
AssetDatabaseV1 = 1004,
|
||||||
Mesh3DSImporter = 1005,
|
Mesh3DSImporter = 1005,
|
||||||
TextureImporter = 1006,
|
TextureImporter = 1006,
|
||||||
ShaderImporter = 1007,
|
ShaderImporter = 1007,
|
||||||
@@ -259,13 +266,13 @@
|
|||||||
AnimatorState = 1102,
|
AnimatorState = 1102,
|
||||||
HumanTemplate = 1105,
|
HumanTemplate = 1105,
|
||||||
AnimatorStateMachine = 1107,
|
AnimatorStateMachine = 1107,
|
||||||
PreviewAssetType = 1108,
|
PreviewAnimationClip = 1108,
|
||||||
AnimatorTransition = 1109,
|
AnimatorTransition = 1109,
|
||||||
SpeedTreeImporter = 1110,
|
SpeedTreeImporter = 1110,
|
||||||
AnimatorTransitionBase = 1111,
|
AnimatorTransitionBase = 1111,
|
||||||
SubstanceImporter = 1112,
|
SubstanceImporter = 1112,
|
||||||
LightmapParameters = 1113,
|
LightmapParameters = 1113,
|
||||||
LightmapSnapshot = 1120,
|
LightingDataAsset = 1120,
|
||||||
GISRaster = 1121,
|
GISRaster = 1121,
|
||||||
GISRasterImporter = 1122,
|
GISRasterImporter = 1122,
|
||||||
CadImporter = 1123,
|
CadImporter = 1123,
|
||||||
@@ -276,11 +283,98 @@
|
|||||||
ActivationLogComponent = 2000,
|
ActivationLogComponent = 2000,
|
||||||
//kLargestEditorClassID = 2001
|
//kLargestEditorClassID = 2001
|
||||||
//kClassIdOutOfHierarchy = 100000
|
//kClassIdOutOfHierarchy = 100000
|
||||||
SubDerived = 367388927,
|
//int = 100000,
|
||||||
|
//bool = 100001,
|
||||||
|
//float = 100002,
|
||||||
|
MonoObject = 100003,
|
||||||
|
Collision = 100004,
|
||||||
|
Vector3f = 100005,
|
||||||
|
RootMotionData = 100006,
|
||||||
|
Collision2D = 100007,
|
||||||
|
AudioMixerLiveUpdateFloat = 100008,
|
||||||
|
AudioMixerLiveUpdateBool = 100009,
|
||||||
|
Polygon2D = 100010,
|
||||||
|
//void = 100011,
|
||||||
|
TilemapCollider2D = 19719996,
|
||||||
|
AssetImporterLog = 41386430,
|
||||||
|
VFXRenderer = 73398921,
|
||||||
|
SerializableManagedRefTestClass = 76251197,
|
||||||
|
Grid = 156049354,
|
||||||
|
ScenesUsingAssets = 156483287,
|
||||||
|
ArticulationBody = 171741748,
|
||||||
|
Preset = 181963792,
|
||||||
|
EmptyObject = 277625683,
|
||||||
|
IConstraint = 285090594,
|
||||||
|
TestObjectWithSpecialLayoutOne = 293259124,
|
||||||
|
AssemblyDefinitionReferenceImporter = 294290339,
|
||||||
SiblingDerived = 334799969,
|
SiblingDerived = 334799969,
|
||||||
|
TestObjectWithSerializedMapStringNonAlignedStruct = 342846651,
|
||||||
|
SubDerived = 367388927,
|
||||||
|
AssetImportInProgressProxy = 369655926,
|
||||||
|
PluginBuildInfo = 382020655,
|
||||||
|
EditorProjectAccess = 426301858,
|
||||||
|
PrefabImporter = 468431735,
|
||||||
|
TestObjectWithSerializedArray = 478637458,
|
||||||
|
TestObjectWithSerializedAnimationCurve = 478637459,
|
||||||
|
TilemapRenderer = 483693784,
|
||||||
|
ScriptableCamera = 488575907,
|
||||||
|
SpriteAtlasAsset = 612988286,
|
||||||
|
SpriteAtlasDatabase = 638013454,
|
||||||
|
AudioBuildInfo = 641289076,
|
||||||
|
CachedSpriteAtlasRuntimeData = 644342135,
|
||||||
|
RendererFake = 646504946,
|
||||||
|
AssemblyDefinitionReferenceAsset = 662584278,
|
||||||
|
BuiltAssetBundleInfoSet = 668709126,
|
||||||
SpriteAtlas = 687078895,
|
SpriteAtlas = 687078895,
|
||||||
|
RayTracingShaderImporter = 747330370,
|
||||||
|
RayTracingShader = 825902497,
|
||||||
|
LightingSettings = 850595691,
|
||||||
|
PlatformModuleSetup = 877146078,
|
||||||
|
VersionControlSettings = 890905787,
|
||||||
|
AimConstraint = 895512359,
|
||||||
|
VFXManager = 937362698,
|
||||||
|
VisualEffectSubgraph = 994735392,
|
||||||
|
VisualEffectSubgraphOperator = 994735403,
|
||||||
|
VisualEffectSubgraphBlock = 994735404,
|
||||||
|
LocalizationImporter = 1027052791,
|
||||||
Derived = 1091556383,
|
Derived = 1091556383,
|
||||||
|
PropertyModificationsTargetTestObject = 1111377672,
|
||||||
|
ReferencesArtifactGenerator = 1114811875,
|
||||||
|
AssemblyDefinitionAsset = 1152215463,
|
||||||
|
SceneVisibilityState = 1154873562,
|
||||||
|
LookAtConstraint = 1183024399,
|
||||||
|
SpriteAtlasImporter = 1210832254,
|
||||||
|
MultiArtifactTestImporter = 1223240404,
|
||||||
|
GameObjectRecorder = 1268269756,
|
||||||
|
LightingDataAssetParent = 1325145578,
|
||||||
|
PresetManager = 1386491679,
|
||||||
|
TestObjectWithSpecialLayoutTwo = 1392443030,
|
||||||
|
StreamingManager = 1403656975,
|
||||||
LowerResBlitTexture = 1480428607,
|
LowerResBlitTexture = 1480428607,
|
||||||
RenderPassAttachment = 1571458007
|
StreamingController = 1542919678,
|
||||||
|
RenderPassAttachment = 1571458007,
|
||||||
|
TestObjectVectorPairStringBool = 1628831178,
|
||||||
|
GridLayout = 1742807556,
|
||||||
|
AssemblyDefinitionImporter = 1766753193,
|
||||||
|
ParentConstraint = 1773428102,
|
||||||
|
FakeComponent = 1803986026,
|
||||||
|
PositionConstraint = 1818360608,
|
||||||
|
RotationConstraint = 1818360609,
|
||||||
|
ScaleConstraint = 1818360610,
|
||||||
|
Tilemap = 1839735485,
|
||||||
|
PackageManifest = 1896753125,
|
||||||
|
PackageManifestImporter = 1896753126,
|
||||||
|
TerrainLayer = 1953259897,
|
||||||
|
SpriteShapeRenderer = 1971053207,
|
||||||
|
NativeObjectType = 1977754360,
|
||||||
|
TestObjectWithSerializedMapStringBool = 1981279845,
|
||||||
|
SerializableManagedHost = 1995898324,
|
||||||
|
VisualEffectAsset = 2058629509,
|
||||||
|
VisualEffectImporter = 2058629510,
|
||||||
|
VisualEffectResource = 2058629511,
|
||||||
|
VisualEffectObject = 2059678085,
|
||||||
|
VisualEffect = 2083052967,
|
||||||
|
LocalizationAsset = 2083778819,
|
||||||
|
ScriptedImporter = 2089858483
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ namespace AssetStudio
|
|||||||
public T inWeight;
|
public T inWeight;
|
||||||
public T outWeight;
|
public T outWeight;
|
||||||
|
|
||||||
|
|
||||||
public Keyframe(ObjectReader reader, Func<T> readerFunc)
|
public Keyframe(ObjectReader reader, Func<T> readerFunc)
|
||||||
{
|
{
|
||||||
time = reader.ReadSingle();
|
time = reader.ReadSingle();
|
||||||
@@ -294,15 +293,20 @@ namespace AssetStudio
|
|||||||
public string path;
|
public string path;
|
||||||
public ClassIDType classID;
|
public ClassIDType classID;
|
||||||
public PPtr<MonoScript> script;
|
public PPtr<MonoScript> script;
|
||||||
|
public int flags;
|
||||||
|
|
||||||
public FloatCurve(ObjectReader reader)
|
public FloatCurve(ObjectReader reader)
|
||||||
{
|
{
|
||||||
|
var version = reader.version;
|
||||||
curve = new AnimationCurve<float>(reader, reader.ReadSingle);
|
curve = new AnimationCurve<float>(reader, reader.ReadSingle);
|
||||||
attribute = reader.ReadAlignedString();
|
attribute = reader.ReadAlignedString();
|
||||||
path = reader.ReadAlignedString();
|
path = reader.ReadAlignedString();
|
||||||
classID = (ClassIDType)reader.ReadInt32();
|
classID = (ClassIDType)reader.ReadInt32();
|
||||||
script = new PPtr<MonoScript>(reader);
|
script = new PPtr<MonoScript>(reader);
|
||||||
|
if (version[0] > 2022 || (version[0] == 2022 && version[1] >= 2)) //2022.2 and up
|
||||||
|
{
|
||||||
|
flags = reader.ReadInt32();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,7 +315,6 @@ namespace AssetStudio
|
|||||||
public float time;
|
public float time;
|
||||||
public PPtr<Object> value;
|
public PPtr<Object> value;
|
||||||
|
|
||||||
|
|
||||||
public PPtrKeyframe(ObjectReader reader)
|
public PPtrKeyframe(ObjectReader reader)
|
||||||
{
|
{
|
||||||
time = reader.ReadSingle();
|
time = reader.ReadSingle();
|
||||||
@@ -326,10 +329,11 @@ namespace AssetStudio
|
|||||||
public string path;
|
public string path;
|
||||||
public int classID;
|
public int classID;
|
||||||
public PPtr<MonoScript> script;
|
public PPtr<MonoScript> script;
|
||||||
|
public int flags;
|
||||||
|
|
||||||
public PPtrCurve(ObjectReader reader)
|
public PPtrCurve(ObjectReader reader)
|
||||||
{
|
{
|
||||||
|
var version = reader.version;
|
||||||
int numCurves = reader.ReadInt32();
|
int numCurves = reader.ReadInt32();
|
||||||
curve = new PPtrKeyframe[numCurves];
|
curve = new PPtrKeyframe[numCurves];
|
||||||
for (int i = 0; i < numCurves; i++)
|
for (int i = 0; i < numCurves; i++)
|
||||||
@@ -341,6 +345,10 @@ namespace AssetStudio
|
|||||||
path = reader.ReadAlignedString();
|
path = reader.ReadAlignedString();
|
||||||
classID = reader.ReadInt32();
|
classID = reader.ReadInt32();
|
||||||
script = new PPtr<MonoScript>(reader);
|
script = new PPtr<MonoScript>(reader);
|
||||||
|
if (version[0] > 2022 || (version[0] == 2022 && version[1] >= 2)) //2022.2 and up
|
||||||
|
{
|
||||||
|
flags = reader.ReadInt32();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -637,6 +645,50 @@ namespace AssetStudio
|
|||||||
m_Binding = new ValueArrayConstant(reader);
|
m_Binding = new ValueArrayConstant(reader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AnimationClipBindingConstant ConvertValueArrayToGenericBinding()
|
||||||
|
{
|
||||||
|
var bindings = new AnimationClipBindingConstant();
|
||||||
|
var genericBindings = new List<GenericBinding>();
|
||||||
|
var values = m_Binding;
|
||||||
|
for (int i = 0; i < values.m_ValueArray.Length;)
|
||||||
|
{
|
||||||
|
var curveID = values.m_ValueArray[i].m_ID;
|
||||||
|
var curveTypeID = values.m_ValueArray[i].m_TypeID;
|
||||||
|
var binding = new GenericBinding();
|
||||||
|
genericBindings.Add(binding);
|
||||||
|
if (curveTypeID == 4174552735) //CRC(PositionX))
|
||||||
|
{
|
||||||
|
binding.path = curveID;
|
||||||
|
binding.attribute = 1; //kBindTransformPosition
|
||||||
|
binding.typeID = ClassIDType.Transform;
|
||||||
|
i += 3;
|
||||||
|
}
|
||||||
|
else if (curveTypeID == 2211994246) //CRC(QuaternionX))
|
||||||
|
{
|
||||||
|
binding.path = curveID;
|
||||||
|
binding.attribute = 2; //kBindTransformRotation
|
||||||
|
binding.typeID = ClassIDType.Transform;
|
||||||
|
i += 4;
|
||||||
|
}
|
||||||
|
else if (curveTypeID == 1512518241) //CRC(ScaleX))
|
||||||
|
{
|
||||||
|
binding.path = curveID;
|
||||||
|
binding.attribute = 3; //kBindTransformScale
|
||||||
|
binding.typeID = ClassIDType.Transform;
|
||||||
|
i += 3;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
binding.typeID = ClassIDType.Animator;
|
||||||
|
binding.path = 0;
|
||||||
|
binding.attribute = curveID;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bindings.genericBindings = genericBindings.ToArray();
|
||||||
|
return bindings;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ValueDelta
|
public class ValueDelta
|
||||||
@@ -753,6 +805,9 @@ namespace AssetStudio
|
|||||||
public ClassIDType typeID;
|
public ClassIDType typeID;
|
||||||
public byte customType;
|
public byte customType;
|
||||||
public byte isPPtrCurve;
|
public byte isPPtrCurve;
|
||||||
|
public byte isIntCurve;
|
||||||
|
|
||||||
|
public GenericBinding() { }
|
||||||
|
|
||||||
public GenericBinding(ObjectReader reader)
|
public GenericBinding(ObjectReader reader)
|
||||||
{
|
{
|
||||||
@@ -770,6 +825,10 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
customType = reader.ReadByte();
|
customType = reader.ReadByte();
|
||||||
isPPtrCurve = reader.ReadByte();
|
isPPtrCurve = reader.ReadByte();
|
||||||
|
if (version[0] > 2022 || (version[0] == 2022 && version[1] >= 1)) //2022.1 and up
|
||||||
|
{
|
||||||
|
isIntCurve = reader.ReadByte();
|
||||||
|
}
|
||||||
reader.AlignStream();
|
reader.AlignStream();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -779,6 +838,8 @@ namespace AssetStudio
|
|||||||
public GenericBinding[] genericBindings;
|
public GenericBinding[] genericBindings;
|
||||||
public PPtr<Object>[] pptrCurveMapping;
|
public PPtr<Object>[] pptrCurveMapping;
|
||||||
|
|
||||||
|
public AnimationClipBindingConstant() { }
|
||||||
|
|
||||||
public AnimationClipBindingConstant(ObjectReader reader)
|
public AnimationClipBindingConstant(ObjectReader reader)
|
||||||
{
|
{
|
||||||
int numBindings = reader.ReadInt32();
|
int numBindings = reader.ReadInt32();
|
||||||
@@ -861,9 +922,9 @@ namespace AssetStudio
|
|||||||
|
|
||||||
public enum AnimationType
|
public enum AnimationType
|
||||||
{
|
{
|
||||||
kLegacy = 1,
|
Legacy = 1,
|
||||||
kGeneric = 2,
|
Generic = 2,
|
||||||
kHumanoid = 3
|
Humanoid = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
public sealed class AnimationClip : NamedObject
|
public sealed class AnimationClip : NamedObject
|
||||||
@@ -887,7 +948,6 @@ namespace AssetStudio
|
|||||||
public AnimationClipBindingConstant m_ClipBindingConstant;
|
public AnimationClipBindingConstant m_ClipBindingConstant;
|
||||||
public AnimationEvent[] m_Events;
|
public AnimationEvent[] m_Events;
|
||||||
|
|
||||||
|
|
||||||
public AnimationClip(ObjectReader reader) : base(reader)
|
public AnimationClip(ObjectReader reader) : base(reader)
|
||||||
{
|
{
|
||||||
if (version[0] >= 5)//5.0 and up
|
if (version[0] >= 5)//5.0 and up
|
||||||
@@ -897,7 +957,7 @@ namespace AssetStudio
|
|||||||
else if (version[0] >= 4)//4.0 and up
|
else if (version[0] >= 4)//4.0 and up
|
||||||
{
|
{
|
||||||
m_AnimationType = (AnimationType)reader.ReadInt32();
|
m_AnimationType = (AnimationType)reader.ReadInt32();
|
||||||
if (m_AnimationType == AnimationType.kLegacy)
|
if (m_AnimationType == AnimationType.Legacy)
|
||||||
m_Legacy = true;
|
m_Legacy = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -31,6 +31,10 @@ namespace AssetStudio
|
|||||||
if (version[0] >= 5) //5.0 and up
|
if (version[0] >= 5) //5.0 and up
|
||||||
{
|
{
|
||||||
var m_LinearVelocityBlending = reader.ReadBoolean();
|
var m_LinearVelocityBlending = reader.ReadBoolean();
|
||||||
|
if (version[0] > 2021 || (version[0] == 2021 && version[1] >= 2)) //2021.2 and up
|
||||||
|
{
|
||||||
|
var m_StabilizeFeet = reader.ReadBoolean();
|
||||||
|
}
|
||||||
reader.AlignStream();
|
reader.AlignStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace AssetStudio
|
namespace AssetStudio
|
||||||
{
|
{
|
||||||
@@ -23,22 +20,47 @@ namespace AssetStudio
|
|||||||
{
|
{
|
||||||
public PPtr<Object>[] m_PreloadTable;
|
public PPtr<Object>[] m_PreloadTable;
|
||||||
public KeyValuePair<string, AssetInfo>[] m_Container;
|
public KeyValuePair<string, AssetInfo>[] m_Container;
|
||||||
|
public string m_AssetBundleName;
|
||||||
|
public string[] m_Dependencies;
|
||||||
|
public bool m_IsStreamedSceneAssetBundle;
|
||||||
|
|
||||||
public AssetBundle(ObjectReader reader) : base(reader)
|
public AssetBundle(ObjectReader reader) : base(reader)
|
||||||
{
|
{
|
||||||
var m_PreloadTableSize = reader.ReadInt32();
|
var m_PreloadTableSize = reader.ReadInt32();
|
||||||
m_PreloadTable = new PPtr<Object>[m_PreloadTableSize];
|
m_PreloadTable = new PPtr<Object>[m_PreloadTableSize];
|
||||||
for (int i = 0; i < m_PreloadTableSize; i++)
|
for (var i = 0; i < m_PreloadTableSize; i++)
|
||||||
{
|
{
|
||||||
m_PreloadTable[i] = new PPtr<Object>(reader);
|
m_PreloadTable[i] = new PPtr<Object>(reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
var m_ContainerSize = reader.ReadInt32();
|
var m_ContainerSize = reader.ReadInt32();
|
||||||
m_Container = new KeyValuePair<string, AssetInfo>[m_ContainerSize];
|
m_Container = new KeyValuePair<string, AssetInfo>[m_ContainerSize];
|
||||||
for (int i = 0; i < m_ContainerSize; i++)
|
for (var i = 0; i < m_ContainerSize; i++)
|
||||||
{
|
{
|
||||||
m_Container[i] = new KeyValuePair<string, AssetInfo>(reader.ReadAlignedString(), new AssetInfo(reader));
|
m_Container[i] = new KeyValuePair<string, AssetInfo>(reader.ReadAlignedString(), new AssetInfo(reader));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var m_MainAsset = new AssetInfo(reader);
|
||||||
|
|
||||||
|
if (version[0] > 4 || (version[0] == 4 && version[1] >= 2)) //4.2 and up
|
||||||
|
{
|
||||||
|
var m_RuntimeCompatibility = reader.ReadUInt32();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (version[0] >= 5) //5.0 and up
|
||||||
|
{
|
||||||
|
m_AssetBundleName = reader.ReadAlignedString();
|
||||||
|
|
||||||
|
var m_DependenciesSize = reader.ReadInt32();
|
||||||
|
m_Dependencies = new string[m_DependenciesSize];
|
||||||
|
|
||||||
|
for (var i = 0; i < m_DependenciesSize; i++)
|
||||||
|
{
|
||||||
|
m_Dependencies[i] = reader.ReadAlignedString();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_IsStreamedSceneAssetBundle = reader.ReadBoolean();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace AssetStudio
|
|||||||
public sealed class AudioClip : NamedObject
|
public sealed class AudioClip : NamedObject
|
||||||
{
|
{
|
||||||
public int m_Format;
|
public int m_Format;
|
||||||
public AudioType m_Type;
|
public FMODSoundType m_Type;
|
||||||
public bool m_3D;
|
public bool m_3D;
|
||||||
public bool m_UseHardware;
|
public bool m_UseHardware;
|
||||||
|
|
||||||
@@ -27,8 +27,8 @@ namespace AssetStudio
|
|||||||
public AudioCompressionFormat m_CompressionFormat;
|
public AudioCompressionFormat m_CompressionFormat;
|
||||||
|
|
||||||
public string m_Source;
|
public string m_Source;
|
||||||
public long m_Offset;
|
public long m_Offset; //ulong
|
||||||
public long m_Size;
|
public long m_Size; //ulong
|
||||||
public ResourceReader m_AudioData;
|
public ResourceReader m_AudioData;
|
||||||
|
|
||||||
public AudioClip(ObjectReader reader) : base(reader)
|
public AudioClip(ObjectReader reader) : base(reader)
|
||||||
@@ -36,7 +36,7 @@ namespace AssetStudio
|
|||||||
if (version[0] < 5)
|
if (version[0] < 5)
|
||||||
{
|
{
|
||||||
m_Format = reader.ReadInt32();
|
m_Format = reader.ReadInt32();
|
||||||
m_Type = (AudioType)reader.ReadInt32();
|
m_Type = (FMODSoundType)reader.ReadInt32();
|
||||||
m_3D = reader.ReadBoolean();
|
m_3D = reader.ReadBoolean();
|
||||||
m_UseHardware = reader.ReadBoolean();
|
m_UseHardware = reader.ReadBoolean();
|
||||||
reader.AlignStream();
|
reader.AlignStream();
|
||||||
@@ -48,7 +48,7 @@ namespace AssetStudio
|
|||||||
var tsize = m_Size % 4 != 0 ? m_Size + 4 - m_Size % 4 : m_Size;
|
var tsize = m_Size % 4 != 0 ? m_Size + 4 - m_Size % 4 : m_Size;
|
||||||
if (reader.byteSize + reader.byteStart - reader.Position != tsize)
|
if (reader.byteSize + reader.byteStart - reader.Position != tsize)
|
||||||
{
|
{
|
||||||
m_Offset = reader.ReadInt32();
|
m_Offset = reader.ReadUInt32();
|
||||||
m_Source = assetsFile.fullName + ".resS";
|
m_Source = assetsFile.fullName + ".resS";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,6 +72,7 @@ namespace AssetStudio
|
|||||||
m_Legacy3D = reader.ReadBoolean();
|
m_Legacy3D = reader.ReadBoolean();
|
||||||
reader.AlignStream();
|
reader.AlignStream();
|
||||||
|
|
||||||
|
//StreamedResource m_Resource
|
||||||
m_Source = reader.ReadAlignedString();
|
m_Source = reader.ReadAlignedString();
|
||||||
m_Offset = reader.ReadInt64();
|
m_Offset = reader.ReadInt64();
|
||||||
m_Size = reader.ReadInt64();
|
m_Size = reader.ReadInt64();
|
||||||
@@ -81,44 +82,61 @@ namespace AssetStudio
|
|||||||
ResourceReader resourceReader;
|
ResourceReader resourceReader;
|
||||||
if (!string.IsNullOrEmpty(m_Source))
|
if (!string.IsNullOrEmpty(m_Source))
|
||||||
{
|
{
|
||||||
resourceReader = new ResourceReader(m_Source, assetsFile, m_Offset, (int)m_Size);
|
resourceReader = new ResourceReader(m_Source, assetsFile, m_Offset, m_Size);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
resourceReader = new ResourceReader(reader, reader.BaseStream.Position, (int)m_Size);
|
resourceReader = new ResourceReader(reader, reader.BaseStream.Position, m_Size);
|
||||||
}
|
}
|
||||||
m_AudioData = resourceReader;
|
m_AudioData = resourceReader;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum AudioType
|
public enum FMODSoundType
|
||||||
{
|
{
|
||||||
UNKNOWN,
|
UNKNOWN = 0,
|
||||||
ACC,
|
ACC = 1,
|
||||||
AIFF,
|
AIFF = 2,
|
||||||
|
ASF = 3,
|
||||||
|
AT3 = 4,
|
||||||
|
CDDA = 5,
|
||||||
|
DLS = 6,
|
||||||
|
FLAC = 7,
|
||||||
|
FSB = 8,
|
||||||
|
GCADPCM = 9,
|
||||||
IT = 10,
|
IT = 10,
|
||||||
|
MIDI = 11,
|
||||||
MOD = 12,
|
MOD = 12,
|
||||||
MPEG,
|
MPEG = 13,
|
||||||
OGGVORBIS,
|
OGGVORBIS = 14,
|
||||||
|
PLAYLIST = 15,
|
||||||
|
RAW = 16,
|
||||||
S3M = 17,
|
S3M = 17,
|
||||||
|
SF2 = 18,
|
||||||
|
USER = 19,
|
||||||
WAV = 20,
|
WAV = 20,
|
||||||
XM,
|
XM = 21,
|
||||||
XMA,
|
XMA = 22,
|
||||||
VAG,
|
VAG = 23,
|
||||||
AUDIOQUEUE
|
AUDIOQUEUE = 24,
|
||||||
|
XWMA = 25,
|
||||||
|
BCWAV = 26,
|
||||||
|
AT9 = 27,
|
||||||
|
VORBIS = 28,
|
||||||
|
MEDIA_FOUNDATION = 29
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum AudioCompressionFormat
|
public enum AudioCompressionFormat
|
||||||
{
|
{
|
||||||
PCM,
|
PCM = 0,
|
||||||
Vorbis,
|
Vorbis = 1,
|
||||||
ADPCM,
|
ADPCM = 2,
|
||||||
MP3,
|
MP3 = 3,
|
||||||
VAG,
|
PSMVAG = 4,
|
||||||
HEVAG,
|
HEVAG = 5,
|
||||||
XMA,
|
XMA = 6,
|
||||||
AAC,
|
AAC = 7,
|
||||||
GCADPCM,
|
GCADPCM = 8,
|
||||||
ATRAC9
|
ATRAC9 = 9
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,11 +19,14 @@ namespace AssetStudio
|
|||||||
public class UnityPropertySheet
|
public class UnityPropertySheet
|
||||||
{
|
{
|
||||||
public KeyValuePair<string, UnityTexEnv>[] m_TexEnvs;
|
public KeyValuePair<string, UnityTexEnv>[] m_TexEnvs;
|
||||||
|
public KeyValuePair<string, int>[] m_Ints;
|
||||||
public KeyValuePair<string, float>[] m_Floats;
|
public KeyValuePair<string, float>[] m_Floats;
|
||||||
public KeyValuePair<string, Color>[] m_Colors;
|
public KeyValuePair<string, Color>[] m_Colors;
|
||||||
|
|
||||||
public UnityPropertySheet(ObjectReader reader)
|
public UnityPropertySheet(ObjectReader reader)
|
||||||
{
|
{
|
||||||
|
var version = reader.version;
|
||||||
|
|
||||||
int m_TexEnvsSize = reader.ReadInt32();
|
int m_TexEnvsSize = reader.ReadInt32();
|
||||||
m_TexEnvs = new KeyValuePair<string, UnityTexEnv>[m_TexEnvsSize];
|
m_TexEnvs = new KeyValuePair<string, UnityTexEnv>[m_TexEnvsSize];
|
||||||
for (int i = 0; i < m_TexEnvsSize; i++)
|
for (int i = 0; i < m_TexEnvsSize; i++)
|
||||||
@@ -31,6 +34,16 @@ namespace AssetStudio
|
|||||||
m_TexEnvs[i] = new KeyValuePair<string, UnityTexEnv>(reader.ReadAlignedString(), new UnityTexEnv(reader));
|
m_TexEnvs[i] = new KeyValuePair<string, UnityTexEnv>(reader.ReadAlignedString(), new UnityTexEnv(reader));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (version[0] >= 2021) //2021.1 and up
|
||||||
|
{
|
||||||
|
int m_IntsSize = reader.ReadInt32();
|
||||||
|
m_Ints = new KeyValuePair<string, int>[m_IntsSize];
|
||||||
|
for (int i = 0; i < m_IntsSize; i++)
|
||||||
|
{
|
||||||
|
m_Ints[i] = new KeyValuePair<string, int>(reader.ReadAlignedString(), reader.ReadInt32());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int m_FloatsSize = reader.ReadInt32();
|
int m_FloatsSize = reader.ReadInt32();
|
||||||
m_Floats = new KeyValuePair<string, float>[m_FloatsSize];
|
m_Floats = new KeyValuePair<string, float>[m_FloatsSize];
|
||||||
for (int i = 0; i < m_FloatsSize; i++)
|
for (int i = 0; i < m_FloatsSize; i++)
|
||||||
@@ -61,9 +74,18 @@ namespace AssetStudio
|
|||||||
var m_ShaderKeywords = reader.ReadStringArray();
|
var m_ShaderKeywords = reader.ReadStringArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (version[0] >= 5) //5.0 and up
|
if (version[0] > 2021 || (version[0] == 2021 && version[1] >= 3)) //2021.3 and up
|
||||||
|
{
|
||||||
|
var m_ValidKeywords = reader.ReadStringArray();
|
||||||
|
var m_InvalidKeywords = reader.ReadStringArray();
|
||||||
|
}
|
||||||
|
else if (version[0] >= 5) //5.0 ~ 2021.2
|
||||||
{
|
{
|
||||||
var m_ShaderKeywords = reader.ReadAlignedString();
|
var m_ShaderKeywords = reader.ReadAlignedString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (version[0] >= 5) //5.0 and up
|
||||||
|
{
|
||||||
var m_LightmapFlags = reader.ReadUInt32();
|
var m_LightmapFlags = reader.ReadUInt32();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,6 +117,8 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_SavedProperties = new UnityPropertySheet(reader);
|
m_SavedProperties = new UnityPropertySheet(reader);
|
||||||
|
|
||||||
|
//vector m_BuildTextureStacks 2020 and up
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ namespace AssetStudio
|
|||||||
GetStreams(version);
|
GetStreams(version);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_DataSize = reader.ReadBytes(reader.ReadInt32());
|
m_DataSize = reader.ReadUInt8Array();
|
||||||
reader.AlignStream();
|
reader.AlignStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,7 +195,7 @@ namespace AssetStudio
|
|||||||
if (m_Channel.dimension > 0)
|
if (m_Channel.dimension > 0)
|
||||||
{
|
{
|
||||||
chnMask |= 1u << chn;
|
chnMask |= 1u << chn;
|
||||||
stride += m_Channel.dimension * MeshHelper.GetFormatSize(version, m_Channel.format);
|
stride += m_Channel.dimension * MeshHelper.GetFormatSize(MeshHelper.ToVertexFormat(m_Channel.format, version));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -253,7 +253,7 @@ namespace AssetStudio
|
|||||||
m_Channel.dimension = 4;
|
m_Channel.dimension = 4;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
offset += (byte)(m_Channel.dimension * MeshHelper.GetFormatSize(version, m_Channel.format));
|
offset += (byte)(m_Channel.dimension * MeshHelper.GetFormatSize(MeshHelper.ToVertexFormat(m_Channel.format, version)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -396,14 +396,14 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum GfxPrimitiveType : int
|
public enum GfxPrimitiveType
|
||||||
{
|
{
|
||||||
kPrimitiveTriangles = 0,
|
Triangles = 0,
|
||||||
kPrimitiveTriangleStrip = 1,
|
TriangleStrip = 1,
|
||||||
kPrimitiveQuads = 2,
|
Quads = 2,
|
||||||
kPrimitiveLines = 3,
|
Lines = 3,
|
||||||
kPrimitiveLineStrip = 4,
|
LineStrip = 4,
|
||||||
kPrimitivePoints = 5,
|
Points = 5
|
||||||
};
|
};
|
||||||
|
|
||||||
public class SubMesh
|
public class SubMesh
|
||||||
@@ -446,7 +446,7 @@ namespace AssetStudio
|
|||||||
|
|
||||||
public sealed class Mesh : NamedObject
|
public sealed class Mesh : NamedObject
|
||||||
{
|
{
|
||||||
private bool m_Use16BitIndices = true; //3.5.0 and newer always uses 16bit indices;
|
private bool m_Use16BitIndices = true;
|
||||||
public SubMesh[] m_SubMeshes;
|
public SubMesh[] m_SubMeshes;
|
||||||
private uint[] m_IndexBuffer;
|
private uint[] m_IndexBuffer;
|
||||||
public BlendShapeData m_Shapes;
|
public BlendShapeData m_Shapes;
|
||||||
@@ -550,6 +550,7 @@ namespace AssetStudio
|
|||||||
((version[0] == 2017 && version[1] == 3) && m_MeshCompression == 0))//2017.3.xfx with no compression
|
((version[0] == 2017 && version[1] == 3) && m_MeshCompression == 0))//2017.3.xfx with no compression
|
||||||
{
|
{
|
||||||
var m_IndexFormat = reader.ReadInt32();
|
var m_IndexFormat = reader.ReadInt32();
|
||||||
|
m_Use16BitIndices = m_IndexFormat == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int m_IndexBuffer_size = reader.ReadInt32();
|
int m_IndexBuffer_size = reader.ReadInt32();
|
||||||
@@ -650,11 +651,16 @@ namespace AssetStudio
|
|||||||
|
|
||||||
int m_MeshUsageFlags = reader.ReadInt32();
|
int m_MeshUsageFlags = reader.ReadInt32();
|
||||||
|
|
||||||
|
if (version[0] > 2022 || (version[0] == 2022 && version[1] >= 1)) //2022.1 and up
|
||||||
|
{
|
||||||
|
int m_CookingOptions = reader.ReadInt32();
|
||||||
|
}
|
||||||
|
|
||||||
if (version[0] >= 5) //5.0 and up
|
if (version[0] >= 5) //5.0 and up
|
||||||
{
|
{
|
||||||
var m_BakedConvexCollisionMesh = reader.ReadBytes(reader.ReadInt32());
|
var m_BakedConvexCollisionMesh = reader.ReadUInt8Array();
|
||||||
reader.AlignStream();
|
reader.AlignStream();
|
||||||
var m_BakedTriangleCollisionMesh = reader.ReadBytes(reader.ReadInt32());
|
var m_BakedTriangleCollisionMesh = reader.ReadUInt8Array();
|
||||||
reader.AlignStream();
|
reader.AlignStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -680,7 +686,7 @@ namespace AssetStudio
|
|||||||
{
|
{
|
||||||
if (m_VertexData.m_VertexCount > 0)
|
if (m_VertexData.m_VertexCount > 0)
|
||||||
{
|
{
|
||||||
var resourceReader = new ResourceReader(m_StreamData.path, assetsFile, m_StreamData.offset, (int)m_StreamData.size);
|
var resourceReader = new ResourceReader(m_StreamData.path, assetsFile, m_StreamData.offset, m_StreamData.size);
|
||||||
m_VertexData.m_DataSize = resourceReader.GetData();
|
m_VertexData.m_DataSize = resourceReader.GetData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -710,12 +716,13 @@ namespace AssetStudio
|
|||||||
var channelMask = new BitArray(new[] { (int)m_Stream.channelMask });
|
var channelMask = new BitArray(new[] { (int)m_Stream.channelMask });
|
||||||
if (channelMask.Get(chn))
|
if (channelMask.Get(chn))
|
||||||
{
|
{
|
||||||
if (version[0] < 2018 && chn == 2 && m_Channel.format == 2)
|
if (version[0] < 2018 && chn == 2 && m_Channel.format == 2) //kShaderChannelColor && kChannelFormatColor
|
||||||
{
|
{
|
||||||
m_Channel.dimension = 4;
|
m_Channel.dimension = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
var componentByteSize = (int)MeshHelper.GetFormatSize(version, m_Channel.format);
|
var vertexFormat = MeshHelper.ToVertexFormat(m_Channel.format, version);
|
||||||
|
var componentByteSize = (int)MeshHelper.GetFormatSize(vertexFormat);
|
||||||
var componentBytes = new byte[m_VertexCount * m_Channel.dimension * componentByteSize];
|
var componentBytes = new byte[m_VertexCount * m_Channel.dimension * componentByteSize];
|
||||||
for (int v = 0; v < m_VertexCount; v++)
|
for (int v = 0; v < m_VertexCount; v++)
|
||||||
{
|
{
|
||||||
@@ -727,7 +734,7 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reader.endian == EndianType.BigEndian && componentByteSize > 1) //swap bytes
|
if (reader.Endian == EndianType.BigEndian && componentByteSize > 1) //swap bytes
|
||||||
{
|
{
|
||||||
for (var i = 0; i < componentBytes.Length / componentByteSize; i++)
|
for (var i = 0; i < componentBytes.Length / componentByteSize; i++)
|
||||||
{
|
{
|
||||||
@@ -740,10 +747,10 @@ namespace AssetStudio
|
|||||||
|
|
||||||
int[] componentsIntArray = null;
|
int[] componentsIntArray = null;
|
||||||
float[] componentsFloatArray = null;
|
float[] componentsFloatArray = null;
|
||||||
if (MeshHelper.IsIntFormat(version, m_Channel.format))
|
if (MeshHelper.IsIntFormat(vertexFormat))
|
||||||
componentsIntArray = MeshHelper.BytesToIntArray(componentBytes, componentByteSize);
|
componentsIntArray = MeshHelper.BytesToIntArray(componentBytes, vertexFormat);
|
||||||
else
|
else
|
||||||
componentsFloatArray = MeshHelper.BytesToFloatArray(componentBytes, componentByteSize);
|
componentsFloatArray = MeshHelper.BytesToFloatArray(componentBytes, vertexFormat);
|
||||||
|
|
||||||
if (version[0] >= 2018)
|
if (version[0] >= 2018)
|
||||||
{
|
{
|
||||||
@@ -1058,7 +1065,7 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
var indexCount = m_SubMesh.indexCount;
|
var indexCount = m_SubMesh.indexCount;
|
||||||
var topology = m_SubMesh.topology;
|
var topology = m_SubMesh.topology;
|
||||||
if (topology == GfxPrimitiveType.kPrimitiveTriangles)
|
if (topology == GfxPrimitiveType.Triangles)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < indexCount; i += 3)
|
for (int i = 0; i < indexCount; i += 3)
|
||||||
{
|
{
|
||||||
@@ -1067,7 +1074,7 @@ namespace AssetStudio
|
|||||||
m_Indices.Add(m_IndexBuffer[firstIndex + i + 2]);
|
m_Indices.Add(m_IndexBuffer[firstIndex + i + 2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (version[0] < 4 || topology == GfxPrimitiveType.kPrimitiveTriangleStrip)
|
else if (version[0] < 4 || topology == GfxPrimitiveType.TriangleStrip)
|
||||||
{
|
{
|
||||||
// de-stripify :
|
// de-stripify :
|
||||||
uint triIndex = 0;
|
uint triIndex = 0;
|
||||||
@@ -1098,7 +1105,7 @@ namespace AssetStudio
|
|||||||
//fix indexCount
|
//fix indexCount
|
||||||
m_SubMesh.indexCount = triIndex;
|
m_SubMesh.indexCount = triIndex;
|
||||||
}
|
}
|
||||||
else if (topology == GfxPrimitiveType.kPrimitiveQuads)
|
else if (topology == GfxPrimitiveType.Quads)
|
||||||
{
|
{
|
||||||
for (int q = 0; q < indexCount; q += 4)
|
for (int q = 0; q < indexCount; q += 4)
|
||||||
{
|
{
|
||||||
@@ -1189,189 +1196,188 @@ namespace AssetStudio
|
|||||||
|
|
||||||
public static class MeshHelper
|
public static class MeshHelper
|
||||||
{
|
{
|
||||||
private enum VertexChannelFormat
|
public enum VertexChannelFormat
|
||||||
{
|
{
|
||||||
kChannelFormatFloat,
|
Float,
|
||||||
kChannelFormatFloat16,
|
Float16,
|
||||||
kChannelFormatColor,
|
Color,
|
||||||
kChannelFormatByte,
|
Byte,
|
||||||
kChannelFormatUInt32
|
UInt32
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum VertexFormat
|
public enum VertexFormat2017
|
||||||
{
|
{
|
||||||
kVertexFormatFloat,
|
Float,
|
||||||
kVertexFormatFloat16,
|
Float16,
|
||||||
kVertexFormatColor,
|
Color,
|
||||||
kVertexFormatUNorm8,
|
UNorm8,
|
||||||
kVertexFormatSNorm8,
|
SNorm8,
|
||||||
kVertexFormatUNorm16,
|
UNorm16,
|
||||||
kVertexFormatSNorm16,
|
SNorm16,
|
||||||
kVertexFormatUInt8,
|
UInt8,
|
||||||
kVertexFormatSInt8,
|
SInt8,
|
||||||
kVertexFormatUInt16,
|
UInt16,
|
||||||
kVertexFormatSInt16,
|
SInt16,
|
||||||
kVertexFormatUInt32,
|
UInt32,
|
||||||
kVertexFormatSInt32
|
SInt32
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum VertexFormatV2019
|
public enum VertexFormat
|
||||||
{
|
{
|
||||||
kVertexFormatFloat,
|
Float,
|
||||||
kVertexFormatFloat16,
|
Float16,
|
||||||
kVertexFormatUNorm8,
|
UNorm8,
|
||||||
kVertexFormatSNorm8,
|
SNorm8,
|
||||||
kVertexFormatUNorm16,
|
UNorm16,
|
||||||
kVertexFormatSNorm16,
|
SNorm16,
|
||||||
kVertexFormatUInt8,
|
UInt8,
|
||||||
kVertexFormatSInt8,
|
SInt8,
|
||||||
kVertexFormatUInt16,
|
UInt16,
|
||||||
kVertexFormatSInt16,
|
SInt16,
|
||||||
kVertexFormatUInt32,
|
UInt32,
|
||||||
kVertexFormatSInt32
|
SInt32
|
||||||
}
|
}
|
||||||
|
|
||||||
public static uint GetFormatSize(int[] version, int format)
|
public static VertexFormat ToVertexFormat(int format, int[] version)
|
||||||
{
|
{
|
||||||
if (version[0] < 2017)
|
if (version[0] < 2017)
|
||||||
{
|
{
|
||||||
switch ((VertexChannelFormat)format)
|
switch ((VertexChannelFormat)format)
|
||||||
{
|
{
|
||||||
case VertexChannelFormat.kChannelFormatFloat:
|
case VertexChannelFormat.Float:
|
||||||
return 4u;
|
return VertexFormat.Float;
|
||||||
case VertexChannelFormat.kChannelFormatFloat16:
|
case VertexChannelFormat.Float16:
|
||||||
return 2u;
|
return VertexFormat.Float16;
|
||||||
case VertexChannelFormat.kChannelFormatColor: //in 4.x is size 4
|
case VertexChannelFormat.Color: //in 4.x is size 4
|
||||||
return 1u;
|
return VertexFormat.UNorm8;
|
||||||
case VertexChannelFormat.kChannelFormatByte:
|
case VertexChannelFormat.Byte:
|
||||||
return 1u;
|
return VertexFormat.UInt8;
|
||||||
case VertexChannelFormat.kChannelFormatUInt32: //in 5.x
|
case VertexChannelFormat.UInt32: //in 5.x
|
||||||
return 4u;
|
return VertexFormat.UInt32;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException(nameof(format), format, null);
|
throw new ArgumentOutOfRangeException(nameof(format), format, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (version[0] < 2019)
|
else if (version[0] < 2019)
|
||||||
{
|
{
|
||||||
switch ((VertexFormat)format)
|
switch ((VertexFormat2017)format)
|
||||||
{
|
{
|
||||||
case VertexFormat.kVertexFormatFloat:
|
case VertexFormat2017.Float:
|
||||||
return 4u;
|
return VertexFormat.Float;
|
||||||
case VertexFormat.kVertexFormatFloat16:
|
case VertexFormat2017.Float16:
|
||||||
return 2u;
|
return VertexFormat.Float16;
|
||||||
case VertexFormat.kVertexFormatColor:
|
case VertexFormat2017.Color:
|
||||||
return 1u;
|
case VertexFormat2017.UNorm8:
|
||||||
case VertexFormat.kVertexFormatUNorm8:
|
return VertexFormat.UNorm8;
|
||||||
return 1u;
|
case VertexFormat2017.SNorm8:
|
||||||
case VertexFormat.kVertexFormatSNorm8:
|
return VertexFormat.SNorm8;
|
||||||
return 1u;
|
case VertexFormat2017.UNorm16:
|
||||||
case VertexFormat.kVertexFormatUNorm16:
|
return VertexFormat.UNorm16;
|
||||||
return 2u;
|
case VertexFormat2017.SNorm16:
|
||||||
case VertexFormat.kVertexFormatSNorm16:
|
return VertexFormat.SNorm16;
|
||||||
return 2u;
|
case VertexFormat2017.UInt8:
|
||||||
case VertexFormat.kVertexFormatUInt8:
|
return VertexFormat.UInt8;
|
||||||
return 1u;
|
case VertexFormat2017.SInt8:
|
||||||
case VertexFormat.kVertexFormatSInt8:
|
return VertexFormat.SInt8;
|
||||||
return 1u;
|
case VertexFormat2017.UInt16:
|
||||||
case VertexFormat.kVertexFormatUInt16:
|
return VertexFormat.UInt16;
|
||||||
return 2u;
|
case VertexFormat2017.SInt16:
|
||||||
case VertexFormat.kVertexFormatSInt16:
|
return VertexFormat.SInt16;
|
||||||
return 2u;
|
case VertexFormat2017.UInt32:
|
||||||
case VertexFormat.kVertexFormatUInt32:
|
return VertexFormat.UInt32;
|
||||||
return 4u;
|
case VertexFormat2017.SInt32:
|
||||||
case VertexFormat.kVertexFormatSInt32:
|
return VertexFormat.SInt32;
|
||||||
return 4u;
|
|
||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException(nameof(format), format, null);
|
throw new ArgumentOutOfRangeException(nameof(format), format, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch ((VertexFormatV2019)format)
|
return (VertexFormat)format;
|
||||||
{
|
|
||||||
case VertexFormatV2019.kVertexFormatFloat:
|
|
||||||
return 4u;
|
|
||||||
case VertexFormatV2019.kVertexFormatFloat16:
|
|
||||||
return 2u;
|
|
||||||
case VertexFormatV2019.kVertexFormatUNorm8:
|
|
||||||
return 1u;
|
|
||||||
case VertexFormatV2019.kVertexFormatSNorm8:
|
|
||||||
return 1u;
|
|
||||||
case VertexFormatV2019.kVertexFormatUNorm16:
|
|
||||||
return 2u;
|
|
||||||
case VertexFormatV2019.kVertexFormatSNorm16:
|
|
||||||
return 2u;
|
|
||||||
case VertexFormatV2019.kVertexFormatUInt8:
|
|
||||||
return 1u;
|
|
||||||
case VertexFormatV2019.kVertexFormatSInt8:
|
|
||||||
return 1u;
|
|
||||||
case VertexFormatV2019.kVertexFormatUInt16:
|
|
||||||
return 2u;
|
|
||||||
case VertexFormatV2019.kVertexFormatSInt16:
|
|
||||||
return 2u;
|
|
||||||
case VertexFormatV2019.kVertexFormatUInt32:
|
|
||||||
return 4u;
|
|
||||||
case VertexFormatV2019.kVertexFormatSInt32:
|
|
||||||
return 4u;
|
|
||||||
default:
|
|
||||||
throw new ArgumentOutOfRangeException(nameof(format), format, null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsIntFormat(int[] version, int format)
|
|
||||||
|
public static uint GetFormatSize(VertexFormat format)
|
||||||
{
|
{
|
||||||
if (version[0] < 2017)
|
switch (format)
|
||||||
{
|
{
|
||||||
return format == 4;
|
case VertexFormat.Float:
|
||||||
}
|
case VertexFormat.UInt32:
|
||||||
else if (version[0] < 2019)
|
case VertexFormat.SInt32:
|
||||||
{
|
return 4u;
|
||||||
return format >= 7;
|
case VertexFormat.Float16:
|
||||||
}
|
case VertexFormat.UNorm16:
|
||||||
else
|
case VertexFormat.SNorm16:
|
||||||
{
|
case VertexFormat.UInt16:
|
||||||
return format >= 6;
|
case VertexFormat.SInt16:
|
||||||
|
return 2u;
|
||||||
|
case VertexFormat.UNorm8:
|
||||||
|
case VertexFormat.SNorm8:
|
||||||
|
case VertexFormat.UInt8:
|
||||||
|
case VertexFormat.SInt8:
|
||||||
|
return 1u;
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException(nameof(format), format, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float[] BytesToFloatArray(byte[] inputBytes, int size)
|
public static bool IsIntFormat(VertexFormat format)
|
||||||
{
|
{
|
||||||
var result = new float[inputBytes.Length / size];
|
return format >= VertexFormat.UInt8;
|
||||||
for (int i = 0; i < inputBytes.Length / size; i++)
|
}
|
||||||
|
|
||||||
|
public static float[] BytesToFloatArray(byte[] inputBytes, VertexFormat format)
|
||||||
|
{
|
||||||
|
var size = GetFormatSize(format);
|
||||||
|
var len = inputBytes.Length / size;
|
||||||
|
var result = new float[len];
|
||||||
|
for (int i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
var value = 0f;
|
switch (format)
|
||||||
switch (size)
|
|
||||||
{
|
{
|
||||||
case 1:
|
case VertexFormat.Float:
|
||||||
value = inputBytes[i] / 255.0f;
|
result[i] = BitConverter.ToSingle(inputBytes, i * 4);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case VertexFormat.Float16:
|
||||||
value = Half.ToHalf(inputBytes, i * 2);
|
result[i] = Half.ToHalf(inputBytes, i * 2);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case VertexFormat.UNorm8:
|
||||||
value = BitConverter.ToSingle(inputBytes, i * 4);
|
result[i] = inputBytes[i] / 255f;
|
||||||
|
break;
|
||||||
|
case VertexFormat.SNorm8:
|
||||||
|
result[i] = Math.Max((sbyte)inputBytes[i] / 127f, -1f);
|
||||||
|
break;
|
||||||
|
case VertexFormat.UNorm16:
|
||||||
|
result[i] = BitConverter.ToUInt16(inputBytes, i * 2) / 65535f;
|
||||||
|
break;
|
||||||
|
case VertexFormat.SNorm16:
|
||||||
|
result[i] = Math.Max(BitConverter.ToInt16(inputBytes, i * 2) / 32767f, -1f);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
result[i] = value;
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int[] BytesToIntArray(byte[] inputBytes, int size)
|
public static int[] BytesToIntArray(byte[] inputBytes, VertexFormat format)
|
||||||
{
|
{
|
||||||
var result = new int[inputBytes.Length / size];
|
var size = GetFormatSize(format);
|
||||||
for (int i = 0; i < inputBytes.Length / size; i++)
|
var len = inputBytes.Length / size;
|
||||||
|
var result = new int[len];
|
||||||
|
for (int i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
switch (size)
|
switch (format)
|
||||||
{
|
{
|
||||||
case 1:
|
case VertexFormat.UInt8:
|
||||||
|
case VertexFormat.SInt8:
|
||||||
result[i] = inputBytes[i];
|
result[i] = inputBytes[i];
|
||||||
break;
|
break;
|
||||||
case 2:
|
case VertexFormat.UInt16:
|
||||||
|
case VertexFormat.SInt16:
|
||||||
result[i] = BitConverter.ToInt16(inputBytes, i * 2);
|
result[i] = BitConverter.ToInt16(inputBytes, i * 2);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case VertexFormat.UInt32:
|
||||||
|
case VertexFormat.SInt32:
|
||||||
result[i] = BitConverter.ToInt32(inputBytes, i * 4);
|
result[i] = BitConverter.ToInt32(inputBytes, i * 4);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace AssetStudio
|
|||||||
public sealed class MonoScript : NamedObject
|
public sealed class MonoScript : NamedObject
|
||||||
{
|
{
|
||||||
public string m_ClassName;
|
public string m_ClassName;
|
||||||
public string m_Namespace = string.Empty;
|
public string m_Namespace;
|
||||||
public string m_AssemblyName;
|
public string m_AssemblyName;
|
||||||
|
|
||||||
public MonoScript(ObjectReader reader) : base(reader)
|
public MonoScript(ObjectReader reader) : base(reader)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace AssetStudio
|
|||||||
var m_Loop = reader.ReadBoolean();
|
var m_Loop = reader.ReadBoolean();
|
||||||
reader.AlignStream();
|
reader.AlignStream();
|
||||||
m_AudioClip = new PPtr<AudioClip>(reader);
|
m_AudioClip = new PPtr<AudioClip>(reader);
|
||||||
m_MovieData = reader.ReadBytes(reader.ReadInt32());
|
m_MovieData = reader.ReadUInt8Array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
using System;
|
using System.Collections.Specialized;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace AssetStudio
|
namespace AssetStudio
|
||||||
{
|
{
|
||||||
@@ -36,19 +33,38 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected bool HasStructMember(string name)
|
|
||||||
{
|
|
||||||
return serializedType?.m_Nodes != null && serializedType.m_Nodes.Any(x => x.m_Name == name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Dump()
|
public string Dump()
|
||||||
{
|
{
|
||||||
reader.Reset();
|
if (serializedType?.m_Type != null)
|
||||||
if (serializedType?.m_Nodes != null)
|
|
||||||
{
|
{
|
||||||
var sb = new StringBuilder();
|
return TypeTreeHelper.ReadTypeString(serializedType.m_Type, reader);
|
||||||
TypeTreeHelper.ReadTypeString(sb, serializedType.m_Nodes, reader);
|
}
|
||||||
return sb.ToString();
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Dump(TypeTree m_Type)
|
||||||
|
{
|
||||||
|
if (m_Type != null)
|
||||||
|
{
|
||||||
|
return TypeTreeHelper.ReadTypeString(m_Type, reader);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrderedDictionary ToType()
|
||||||
|
{
|
||||||
|
if (serializedType?.m_Type != null)
|
||||||
|
{
|
||||||
|
return TypeTreeHelper.ReadType(serializedType.m_Type, reader);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrderedDictionary ToType(TypeTree m_Type)
|
||||||
|
{
|
||||||
|
if (m_Type != null)
|
||||||
|
{
|
||||||
|
return TypeTreeHelper.ReadType(m_Type, reader);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace AssetStudio
|
|||||||
public PPtr(ObjectReader reader)
|
public PPtr(ObjectReader reader)
|
||||||
{
|
{
|
||||||
m_FileID = reader.ReadInt32();
|
m_FileID = reader.ReadInt32();
|
||||||
m_PathID = reader.m_Version < 14 ? reader.ReadInt32() : reader.ReadInt64();
|
m_PathID = reader.m_Version < SerializedFileFormatVersion.Unknown_14 ? reader.ReadInt32() : reader.ReadInt64();
|
||||||
assetsFile = reader.assetsFile;
|
assetsFile = reader.assetsFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
35
AssetStudio/Classes/PreloadData.cs
Normal file
35
AssetStudio/Classes/PreloadData.cs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
namespace AssetStudio
|
||||||
|
{
|
||||||
|
public sealed class PreloadData : NamedObject
|
||||||
|
{
|
||||||
|
public PPtr<Object>[] m_Assets;
|
||||||
|
|
||||||
|
public PreloadData(ObjectReader reader) : base(reader)
|
||||||
|
{
|
||||||
|
var m_PreloadTableSize = reader.ReadInt32();
|
||||||
|
m_Assets = new PPtr<Object>[m_PreloadTableSize];
|
||||||
|
for (var i = 0; i < m_PreloadTableSize; i++)
|
||||||
|
{
|
||||||
|
m_Assets[i] = new PPtr<Object>(reader);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (version[0] >= 5) //5.0 and up
|
||||||
|
{
|
||||||
|
var m_DependenciesSize = reader.ReadInt32();
|
||||||
|
var m_Dependencies = new string[m_DependenciesSize];
|
||||||
|
|
||||||
|
for (var i = 0; i < m_DependenciesSize; i++)
|
||||||
|
{
|
||||||
|
m_Dependencies[i] = reader.ReadAlignedString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (version[0] > 2018 || (version[0] == 2018 && version[1] >= 2)) //2018.2 and up
|
||||||
|
{
|
||||||
|
var m_ExplicitDataLayout = reader.ReadBoolean();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -43,6 +43,10 @@ namespace AssetStudio
|
|||||||
{
|
{
|
||||||
var m_DynamicOccludee = reader.ReadByte();
|
var m_DynamicOccludee = reader.ReadByte();
|
||||||
}
|
}
|
||||||
|
if (version[0] >= 2021) //2021.1 and up
|
||||||
|
{
|
||||||
|
var m_StaticShadowCaster = reader.ReadByte();
|
||||||
|
}
|
||||||
var m_MotionVectors = reader.ReadByte();
|
var m_MotionVectors = reader.ReadByte();
|
||||||
var m_LightProbeUsage = reader.ReadByte();
|
var m_LightProbeUsage = reader.ReadByte();
|
||||||
var m_ReflectionProbeUsage = reader.ReadByte();
|
var m_ReflectionProbeUsage = reader.ReadByte();
|
||||||
@@ -50,6 +54,10 @@ namespace AssetStudio
|
|||||||
{
|
{
|
||||||
var m_RayTracingMode = reader.ReadByte();
|
var m_RayTracingMode = reader.ReadByte();
|
||||||
}
|
}
|
||||||
|
if (version[0] >= 2020) //2020.1 and up
|
||||||
|
{
|
||||||
|
var m_RayTraceProcedural = reader.ReadByte();
|
||||||
|
}
|
||||||
reader.AlignStream();
|
reader.AlignStream();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
19
AssetStudio/Classes/ResourceManager.cs
Normal file
19
AssetStudio/Classes/ResourceManager.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace AssetStudio
|
||||||
|
{
|
||||||
|
public class ResourceManager : Object
|
||||||
|
{
|
||||||
|
public KeyValuePair<string, PPtr<Object>>[] m_Container;
|
||||||
|
|
||||||
|
public ResourceManager(ObjectReader reader) : base(reader)
|
||||||
|
{
|
||||||
|
var m_ContainerSize = reader.ReadInt32();
|
||||||
|
m_Container = new KeyValuePair<string, PPtr<Object>>[m_ContainerSize];
|
||||||
|
for (int i = 0; i < m_ContainerSize; i++)
|
||||||
|
{
|
||||||
|
m_Container[i] = new KeyValuePair<string, PPtr<Object>>(reader.ReadAlignedString(), new PPtr<Object>(reader));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,16 @@ using System.Linq;
|
|||||||
|
|
||||||
namespace AssetStudio
|
namespace AssetStudio
|
||||||
{
|
{
|
||||||
|
public class Hash128
|
||||||
|
{
|
||||||
|
public byte[] bytes;
|
||||||
|
|
||||||
|
public Hash128(BinaryReader reader)
|
||||||
|
{
|
||||||
|
bytes = reader.ReadBytes(16);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class StructParameter
|
public class StructParameter
|
||||||
{
|
{
|
||||||
public MatrixParameter[] m_MatrixParams;
|
public MatrixParameter[] m_MatrixParams;
|
||||||
@@ -46,15 +56,14 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
public enum TextureDimension
|
public enum TextureDimension
|
||||||
{
|
{
|
||||||
kTexDimUnknown = -1,
|
Unknown = -1,
|
||||||
kTexDimNone = 0,
|
None = 0,
|
||||||
kTexDimAny = 1,
|
Any = 1,
|
||||||
kTexDim2D = 2,
|
Tex2D = 2,
|
||||||
kTexDim3D = 3,
|
Tex3D = 3,
|
||||||
kTexDimCUBE = 4,
|
Cube = 4,
|
||||||
kTexDim2DArray = 5,
|
Tex2DArray = 5,
|
||||||
kTexDimCubeArray = 6,
|
CubeArray = 6
|
||||||
kTexDimForce32Bit = 2147483647
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public class SerializedTextureProperty
|
public class SerializedTextureProperty
|
||||||
@@ -71,11 +80,12 @@ namespace AssetStudio
|
|||||||
|
|
||||||
public enum SerializedPropertyType
|
public enum SerializedPropertyType
|
||||||
{
|
{
|
||||||
kColor = 0,
|
Color = 0,
|
||||||
kVector = 1,
|
Vector = 1,
|
||||||
kFloat = 2,
|
Float = 2,
|
||||||
kRange = 3,
|
Range = 3,
|
||||||
kTexture = 4
|
Texture = 4,
|
||||||
|
Int = 5
|
||||||
};
|
};
|
||||||
|
|
||||||
public class SerializedProperty
|
public class SerializedProperty
|
||||||
@@ -185,11 +195,11 @@ namespace AssetStudio
|
|||||||
|
|
||||||
public enum FogMode
|
public enum FogMode
|
||||||
{
|
{
|
||||||
kFogUnknown = -1,
|
Unknown = -1,
|
||||||
kFogDisabled = 0,
|
Disabled = 0,
|
||||||
kFogLinear = 1,
|
Linear = 1,
|
||||||
kFogExp = 2,
|
Exp = 2,
|
||||||
kFogExp2 = 3
|
Exp2 = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
public class SerializedShaderState
|
public class SerializedShaderState
|
||||||
@@ -201,6 +211,7 @@ namespace AssetStudio
|
|||||||
public SerializedShaderFloatValue zTest;
|
public SerializedShaderFloatValue zTest;
|
||||||
public SerializedShaderFloatValue zWrite;
|
public SerializedShaderFloatValue zWrite;
|
||||||
public SerializedShaderFloatValue culling;
|
public SerializedShaderFloatValue culling;
|
||||||
|
public SerializedShaderFloatValue conservative;
|
||||||
public SerializedShaderFloatValue offsetFactor;
|
public SerializedShaderFloatValue offsetFactor;
|
||||||
public SerializedShaderFloatValue offsetUnits;
|
public SerializedShaderFloatValue offsetUnits;
|
||||||
public SerializedShaderFloatValue alphaToMask;
|
public SerializedShaderFloatValue alphaToMask;
|
||||||
@@ -239,6 +250,10 @@ namespace AssetStudio
|
|||||||
zTest = new SerializedShaderFloatValue(reader);
|
zTest = new SerializedShaderFloatValue(reader);
|
||||||
zWrite = new SerializedShaderFloatValue(reader);
|
zWrite = new SerializedShaderFloatValue(reader);
|
||||||
culling = new SerializedShaderFloatValue(reader);
|
culling = new SerializedShaderFloatValue(reader);
|
||||||
|
if (version[0] >= 2020) //2020.1 and up
|
||||||
|
{
|
||||||
|
conservative = new SerializedShaderFloatValue(reader);
|
||||||
|
}
|
||||||
offsetFactor = new SerializedShaderFloatValue(reader);
|
offsetFactor = new SerializedShaderFloatValue(reader);
|
||||||
offsetUnits = new SerializedShaderFloatValue(reader);
|
offsetUnits = new SerializedShaderFloatValue(reader);
|
||||||
alphaToMask = new SerializedShaderFloatValue(reader);
|
alphaToMask = new SerializedShaderFloatValue(reader);
|
||||||
@@ -357,11 +372,18 @@ namespace AssetStudio
|
|||||||
{
|
{
|
||||||
public int m_NameIndex;
|
public int m_NameIndex;
|
||||||
public int m_Index;
|
public int m_Index;
|
||||||
|
public int m_ArraySize;
|
||||||
|
|
||||||
public BufferBinding(BinaryReader reader)
|
public BufferBinding(ObjectReader reader)
|
||||||
{
|
{
|
||||||
|
var version = reader.version;
|
||||||
|
|
||||||
m_NameIndex = reader.ReadInt32();
|
m_NameIndex = reader.ReadInt32();
|
||||||
m_Index = reader.ReadInt32();
|
m_Index = reader.ReadInt32();
|
||||||
|
if (version[0] >= 2020) //2020.1 and up
|
||||||
|
{
|
||||||
|
m_ArraySize = reader.ReadInt32();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,6 +394,7 @@ namespace AssetStudio
|
|||||||
public VectorParameter[] m_VectorParams;
|
public VectorParameter[] m_VectorParams;
|
||||||
public StructParameter[] m_StructParams;
|
public StructParameter[] m_StructParams;
|
||||||
public int m_Size;
|
public int m_Size;
|
||||||
|
public bool m_IsPartialCB;
|
||||||
|
|
||||||
public ConstantBuffer(ObjectReader reader)
|
public ConstantBuffer(ObjectReader reader)
|
||||||
{
|
{
|
||||||
@@ -402,6 +425,16 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_Size = reader.ReadInt32();
|
m_Size = reader.ReadInt32();
|
||||||
|
|
||||||
|
if ((version[0] == 2020 && version[1] > 3) ||
|
||||||
|
(version[0] == 2020 && version[1] == 3 && version[2] >= 2) || //2020.3.2f1 and up
|
||||||
|
(version[0] > 2021) ||
|
||||||
|
(version[0] == 2021 && version[1] > 1) ||
|
||||||
|
(version[0] == 2021 && version[1] == 1 && version[2] >= 4)) //2021.1.4f1 and up
|
||||||
|
{
|
||||||
|
m_IsPartialCB = reader.ReadBoolean();
|
||||||
|
reader.AlignStream();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -421,42 +454,43 @@ namespace AssetStudio
|
|||||||
|
|
||||||
public enum ShaderGpuProgramType
|
public enum ShaderGpuProgramType
|
||||||
{
|
{
|
||||||
kShaderGpuProgramUnknown = 0,
|
Unknown = 0,
|
||||||
kShaderGpuProgramGLLegacy = 1,
|
GLLegacy = 1,
|
||||||
kShaderGpuProgramGLES31AEP = 2,
|
GLES31AEP = 2,
|
||||||
kShaderGpuProgramGLES31 = 3,
|
GLES31 = 3,
|
||||||
kShaderGpuProgramGLES3 = 4,
|
GLES3 = 4,
|
||||||
kShaderGpuProgramGLES = 5,
|
GLES = 5,
|
||||||
kShaderGpuProgramGLCore32 = 6,
|
GLCore32 = 6,
|
||||||
kShaderGpuProgramGLCore41 = 7,
|
GLCore41 = 7,
|
||||||
kShaderGpuProgramGLCore43 = 8,
|
GLCore43 = 8,
|
||||||
kShaderGpuProgramDX9VertexSM20 = 9,
|
DX9VertexSM20 = 9,
|
||||||
kShaderGpuProgramDX9VertexSM30 = 10,
|
DX9VertexSM30 = 10,
|
||||||
kShaderGpuProgramDX9PixelSM20 = 11,
|
DX9PixelSM20 = 11,
|
||||||
kShaderGpuProgramDX9PixelSM30 = 12,
|
DX9PixelSM30 = 12,
|
||||||
kShaderGpuProgramDX10Level9Vertex = 13,
|
DX10Level9Vertex = 13,
|
||||||
kShaderGpuProgramDX10Level9Pixel = 14,
|
DX10Level9Pixel = 14,
|
||||||
kShaderGpuProgramDX11VertexSM40 = 15,
|
DX11VertexSM40 = 15,
|
||||||
kShaderGpuProgramDX11VertexSM50 = 16,
|
DX11VertexSM50 = 16,
|
||||||
kShaderGpuProgramDX11PixelSM40 = 17,
|
DX11PixelSM40 = 17,
|
||||||
kShaderGpuProgramDX11PixelSM50 = 18,
|
DX11PixelSM50 = 18,
|
||||||
kShaderGpuProgramDX11GeometrySM40 = 19,
|
DX11GeometrySM40 = 19,
|
||||||
kShaderGpuProgramDX11GeometrySM50 = 20,
|
DX11GeometrySM50 = 20,
|
||||||
kShaderGpuProgramDX11HullSM50 = 21,
|
DX11HullSM50 = 21,
|
||||||
kShaderGpuProgramDX11DomainSM50 = 22,
|
DX11DomainSM50 = 22,
|
||||||
kShaderGpuProgramMetalVS = 23,
|
MetalVS = 23,
|
||||||
kShaderGpuProgramMetalFS = 24,
|
MetalFS = 24,
|
||||||
kShaderGpuProgramSPIRV = 25,
|
SPIRV = 25,
|
||||||
kShaderGpuProgramConsole = 26
|
ConsoleVS = 26,
|
||||||
|
ConsoleFS = 27,
|
||||||
|
ConsoleHS = 28,
|
||||||
|
ConsoleDS = 29,
|
||||||
|
ConsoleGS = 30,
|
||||||
|
RayTracing = 31,
|
||||||
|
PS5NGGC = 32
|
||||||
};
|
};
|
||||||
|
|
||||||
public class SerializedSubProgram
|
public class SerializedProgramParameters
|
||||||
{
|
{
|
||||||
public uint m_BlobIndex;
|
|
||||||
public ParserBindChannels m_Channels;
|
|
||||||
public ushort[] m_KeywordIndices;
|
|
||||||
public sbyte m_ShaderHardwareTier;
|
|
||||||
public ShaderGpuProgramType m_GpuProgramType;
|
|
||||||
public VectorParameter[] m_VectorParams;
|
public VectorParameter[] m_VectorParams;
|
||||||
public MatrixParameter[] m_MatrixParams;
|
public MatrixParameter[] m_MatrixParams;
|
||||||
public TextureParameter[] m_TextureParams;
|
public TextureParameter[] m_TextureParams;
|
||||||
@@ -466,33 +500,8 @@ namespace AssetStudio
|
|||||||
public UAVParameter[] m_UAVParams;
|
public UAVParameter[] m_UAVParams;
|
||||||
public SamplerParameter[] m_Samplers;
|
public SamplerParameter[] m_Samplers;
|
||||||
|
|
||||||
public SerializedSubProgram(ObjectReader reader)
|
public SerializedProgramParameters(ObjectReader reader)
|
||||||
{
|
{
|
||||||
var version = reader.version;
|
|
||||||
|
|
||||||
m_BlobIndex = reader.ReadUInt32();
|
|
||||||
m_Channels = new ParserBindChannels(reader);
|
|
||||||
|
|
||||||
if (version[0] >= 2019) //2019 and up
|
|
||||||
{
|
|
||||||
var m_GlobalKeywordIndices = reader.ReadUInt16Array();
|
|
||||||
reader.AlignStream();
|
|
||||||
var m_LocalKeywordIndices = reader.ReadUInt16Array();
|
|
||||||
reader.AlignStream();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_KeywordIndices = reader.ReadUInt16Array();
|
|
||||||
if (version[0] >= 2017) //2017 and up
|
|
||||||
{
|
|
||||||
reader.AlignStream();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_ShaderHardwareTier = reader.ReadSByte();
|
|
||||||
m_GpuProgramType = (ShaderGpuProgramType)reader.ReadSByte();
|
|
||||||
reader.AlignStream();
|
|
||||||
|
|
||||||
int numVectorParams = reader.ReadInt32();
|
int numVectorParams = reader.ReadInt32();
|
||||||
m_VectorParams = new VectorParameter[numVectorParams];
|
m_VectorParams = new VectorParameter[numVectorParams];
|
||||||
for (int i = 0; i < numVectorParams; i++)
|
for (int i = 0; i < numVectorParams; i++)
|
||||||
@@ -542,18 +551,139 @@ namespace AssetStudio
|
|||||||
m_UAVParams[i] = new UAVParameter(reader);
|
m_UAVParams[i] = new UAVParameter(reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (version[0] >= 2017) //2017 and up
|
int numSamplers = reader.ReadInt32();
|
||||||
|
m_Samplers = new SamplerParameter[numSamplers];
|
||||||
|
for (int i = 0; i < numSamplers; i++)
|
||||||
{
|
{
|
||||||
int numSamplers = reader.ReadInt32();
|
m_Samplers[i] = new SamplerParameter(reader);
|
||||||
m_Samplers = new SamplerParameter[numSamplers];
|
}
|
||||||
for (int i = 0; i < numSamplers; i++)
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SerializedSubProgram
|
||||||
|
{
|
||||||
|
public uint m_BlobIndex;
|
||||||
|
public ParserBindChannels m_Channels;
|
||||||
|
public ushort[] m_KeywordIndices;
|
||||||
|
public sbyte m_ShaderHardwareTier;
|
||||||
|
public ShaderGpuProgramType m_GpuProgramType;
|
||||||
|
public SerializedProgramParameters m_Parameters;
|
||||||
|
public VectorParameter[] m_VectorParams;
|
||||||
|
public MatrixParameter[] m_MatrixParams;
|
||||||
|
public TextureParameter[] m_TextureParams;
|
||||||
|
public BufferBinding[] m_BufferParams;
|
||||||
|
public ConstantBuffer[] m_ConstantBuffers;
|
||||||
|
public BufferBinding[] m_ConstantBufferBindings;
|
||||||
|
public UAVParameter[] m_UAVParams;
|
||||||
|
public SamplerParameter[] m_Samplers;
|
||||||
|
|
||||||
|
public SerializedSubProgram(ObjectReader reader)
|
||||||
|
{
|
||||||
|
var version = reader.version;
|
||||||
|
|
||||||
|
m_BlobIndex = reader.ReadUInt32();
|
||||||
|
m_Channels = new ParserBindChannels(reader);
|
||||||
|
|
||||||
|
if ((version[0] >= 2019 && version[0] < 2021) || (version[0] == 2021 && version[1] < 2)) //2019 ~2021.1
|
||||||
|
{
|
||||||
|
var m_GlobalKeywordIndices = reader.ReadUInt16Array();
|
||||||
|
reader.AlignStream();
|
||||||
|
var m_LocalKeywordIndices = reader.ReadUInt16Array();
|
||||||
|
reader.AlignStream();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_KeywordIndices = reader.ReadUInt16Array();
|
||||||
|
if (version[0] >= 2017) //2017 and up
|
||||||
{
|
{
|
||||||
m_Samplers[i] = new SamplerParameter(reader);
|
reader.AlignStream();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_ShaderHardwareTier = reader.ReadSByte();
|
||||||
|
m_GpuProgramType = (ShaderGpuProgramType)reader.ReadSByte();
|
||||||
|
reader.AlignStream();
|
||||||
|
|
||||||
|
if ((version[0] == 2020 && version[1] > 3) ||
|
||||||
|
(version[0] == 2020 && version[1] == 3 && version[2] >= 2) || //2020.3.2f1 and up
|
||||||
|
(version[0] > 2021) ||
|
||||||
|
(version[0] == 2021 && version[1] > 1) ||
|
||||||
|
(version[0] == 2021 && version[1] == 1 && version[2] >= 1)) //2021.1.1f1 and up
|
||||||
|
{
|
||||||
|
m_Parameters = new SerializedProgramParameters(reader);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int numVectorParams = reader.ReadInt32();
|
||||||
|
m_VectorParams = new VectorParameter[numVectorParams];
|
||||||
|
for (int i = 0; i < numVectorParams; i++)
|
||||||
|
{
|
||||||
|
m_VectorParams[i] = new VectorParameter(reader);
|
||||||
|
}
|
||||||
|
|
||||||
|
int numMatrixParams = reader.ReadInt32();
|
||||||
|
m_MatrixParams = new MatrixParameter[numMatrixParams];
|
||||||
|
for (int i = 0; i < numMatrixParams; i++)
|
||||||
|
{
|
||||||
|
m_MatrixParams[i] = new MatrixParameter(reader);
|
||||||
|
}
|
||||||
|
|
||||||
|
int numTextureParams = reader.ReadInt32();
|
||||||
|
m_TextureParams = new TextureParameter[numTextureParams];
|
||||||
|
for (int i = 0; i < numTextureParams; i++)
|
||||||
|
{
|
||||||
|
m_TextureParams[i] = new TextureParameter(reader);
|
||||||
|
}
|
||||||
|
|
||||||
|
int numBufferParams = reader.ReadInt32();
|
||||||
|
m_BufferParams = new BufferBinding[numBufferParams];
|
||||||
|
for (int i = 0; i < numBufferParams; i++)
|
||||||
|
{
|
||||||
|
m_BufferParams[i] = new BufferBinding(reader);
|
||||||
|
}
|
||||||
|
|
||||||
|
int numConstantBuffers = reader.ReadInt32();
|
||||||
|
m_ConstantBuffers = new ConstantBuffer[numConstantBuffers];
|
||||||
|
for (int i = 0; i < numConstantBuffers; i++)
|
||||||
|
{
|
||||||
|
m_ConstantBuffers[i] = new ConstantBuffer(reader);
|
||||||
|
}
|
||||||
|
|
||||||
|
int numConstantBufferBindings = reader.ReadInt32();
|
||||||
|
m_ConstantBufferBindings = new BufferBinding[numConstantBufferBindings];
|
||||||
|
for (int i = 0; i < numConstantBufferBindings; i++)
|
||||||
|
{
|
||||||
|
m_ConstantBufferBindings[i] = new BufferBinding(reader);
|
||||||
|
}
|
||||||
|
|
||||||
|
int numUAVParams = reader.ReadInt32();
|
||||||
|
m_UAVParams = new UAVParameter[numUAVParams];
|
||||||
|
for (int i = 0; i < numUAVParams; i++)
|
||||||
|
{
|
||||||
|
m_UAVParams[i] = new UAVParameter(reader);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (version[0] >= 2017) //2017 and up
|
||||||
|
{
|
||||||
|
int numSamplers = reader.ReadInt32();
|
||||||
|
m_Samplers = new SamplerParameter[numSamplers];
|
||||||
|
for (int i = 0; i < numSamplers; i++)
|
||||||
|
{
|
||||||
|
m_Samplers[i] = new SamplerParameter(reader);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 2)) //2017.2 and up
|
if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 2)) //2017.2 and up
|
||||||
{
|
{
|
||||||
var m_ShaderRequirements = reader.ReadInt32();
|
if (version[0] >= 2021) //2021.1 and up
|
||||||
|
{
|
||||||
|
var m_ShaderRequirements = reader.ReadInt64();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var m_ShaderRequirements = reader.ReadInt32();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -561,27 +691,50 @@ namespace AssetStudio
|
|||||||
public class SerializedProgram
|
public class SerializedProgram
|
||||||
{
|
{
|
||||||
public SerializedSubProgram[] m_SubPrograms;
|
public SerializedSubProgram[] m_SubPrograms;
|
||||||
|
public SerializedProgramParameters m_CommonParameters;
|
||||||
|
public ushort[] m_SerializedKeywordStateMask;
|
||||||
|
|
||||||
public SerializedProgram(ObjectReader reader)
|
public SerializedProgram(ObjectReader reader)
|
||||||
{
|
{
|
||||||
|
var version = reader.version;
|
||||||
|
|
||||||
int numSubPrograms = reader.ReadInt32();
|
int numSubPrograms = reader.ReadInt32();
|
||||||
m_SubPrograms = new SerializedSubProgram[numSubPrograms];
|
m_SubPrograms = new SerializedSubProgram[numSubPrograms];
|
||||||
for (int i = 0; i < numSubPrograms; i++)
|
for (int i = 0; i < numSubPrograms; i++)
|
||||||
{
|
{
|
||||||
m_SubPrograms[i] = new SerializedSubProgram(reader);
|
m_SubPrograms[i] = new SerializedSubProgram(reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((version[0] == 2020 && version[1] > 3) ||
|
||||||
|
(version[0] == 2020 && version[1] == 3 && version[2] >= 2) || //2020.3.2f1 and up
|
||||||
|
(version[0] > 2021) ||
|
||||||
|
(version[0] == 2021 && version[1] > 1) ||
|
||||||
|
(version[0] == 2021 && version[1] == 1 && version[2] >= 1)) //2021.1.1f1 and up
|
||||||
|
{
|
||||||
|
m_CommonParameters = new SerializedProgramParameters(reader);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (version[0] > 2022 || (version[0] == 2022 && version[1] >= 1)) //2022.1 and up
|
||||||
|
{
|
||||||
|
m_SerializedKeywordStateMask = reader.ReadUInt16Array();
|
||||||
|
reader.AlignStream();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum PassType
|
public enum PassType
|
||||||
{
|
{
|
||||||
kPassTypeNormal = 0,
|
Normal = 0,
|
||||||
kPassTypeUse = 1,
|
Use = 1,
|
||||||
kPassTypeGrab = 2
|
Grab = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
public class SerializedPass
|
public class SerializedPass
|
||||||
{
|
{
|
||||||
|
public Hash128[] m_EditorDataHash;
|
||||||
|
public byte[] m_Platforms;
|
||||||
|
public ushort[] m_LocalKeywordMask;
|
||||||
|
public ushort[] m_GlobalKeywordMask;
|
||||||
public KeyValuePair<string, int>[] m_NameIndices;
|
public KeyValuePair<string, int>[] m_NameIndices;
|
||||||
public PassType m_Type;
|
public PassType m_Type;
|
||||||
public SerializedShaderState m_State;
|
public SerializedShaderState m_State;
|
||||||
@@ -597,11 +750,32 @@ namespace AssetStudio
|
|||||||
public string m_Name;
|
public string m_Name;
|
||||||
public string m_TextureName;
|
public string m_TextureName;
|
||||||
public SerializedTagMap m_Tags;
|
public SerializedTagMap m_Tags;
|
||||||
|
public ushort[] m_SerializedKeywordStateMask;
|
||||||
|
|
||||||
public SerializedPass(ObjectReader reader)
|
public SerializedPass(ObjectReader reader)
|
||||||
{
|
{
|
||||||
var version = reader.version;
|
var version = reader.version;
|
||||||
|
|
||||||
|
if (version[0] > 2020 || (version[0] == 2020 && version[1] >= 2)) //2020.2 and up
|
||||||
|
{
|
||||||
|
int numEditorDataHash = reader.ReadInt32();
|
||||||
|
m_EditorDataHash = new Hash128[numEditorDataHash];
|
||||||
|
for (int i = 0; i < numEditorDataHash; i++)
|
||||||
|
{
|
||||||
|
m_EditorDataHash[i] = new Hash128(reader);
|
||||||
|
}
|
||||||
|
reader.AlignStream();
|
||||||
|
m_Platforms = reader.ReadUInt8Array();
|
||||||
|
reader.AlignStream();
|
||||||
|
if (version[0] < 2021 || (version[0] == 2021 && version[1] < 2)) //2021.1 and down
|
||||||
|
{
|
||||||
|
m_LocalKeywordMask = reader.ReadUInt16Array();
|
||||||
|
reader.AlignStream();
|
||||||
|
m_GlobalKeywordMask = reader.ReadUInt16Array();
|
||||||
|
reader.AlignStream();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int numIndices = reader.ReadInt32();
|
int numIndices = reader.ReadInt32();
|
||||||
m_NameIndices = new KeyValuePair<string, int>[numIndices];
|
m_NameIndices = new KeyValuePair<string, int>[numIndices];
|
||||||
for (int i = 0; i < numIndices; i++)
|
for (int i = 0; i < numIndices; i++)
|
||||||
@@ -631,6 +805,11 @@ namespace AssetStudio
|
|||||||
m_Name = reader.ReadAlignedString();
|
m_Name = reader.ReadAlignedString();
|
||||||
m_TextureName = reader.ReadAlignedString();
|
m_TextureName = reader.ReadAlignedString();
|
||||||
m_Tags = new SerializedTagMap(reader);
|
m_Tags = new SerializedTagMap(reader);
|
||||||
|
if (version[0] == 2021 && version[1] >= 2) //2021.2 ~2021.x
|
||||||
|
{
|
||||||
|
m_SerializedKeywordStateMask = reader.ReadUInt16Array();
|
||||||
|
reader.AlignStream();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -681,18 +860,35 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class SerializedCustomEditorForRenderPipeline
|
||||||
|
{
|
||||||
|
public string customEditorName;
|
||||||
|
public string renderPipelineType;
|
||||||
|
|
||||||
|
public SerializedCustomEditorForRenderPipeline(BinaryReader reader)
|
||||||
|
{
|
||||||
|
customEditorName = reader.ReadAlignedString();
|
||||||
|
renderPipelineType = reader.ReadAlignedString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class SerializedShader
|
public class SerializedShader
|
||||||
{
|
{
|
||||||
public SerializedProperties m_PropInfo;
|
public SerializedProperties m_PropInfo;
|
||||||
public SerializedSubShader[] m_SubShaders;
|
public SerializedSubShader[] m_SubShaders;
|
||||||
|
public string[] m_KeywordNames;
|
||||||
|
public byte[] m_KeywordFlags;
|
||||||
public string m_Name;
|
public string m_Name;
|
||||||
public string m_CustomEditorName;
|
public string m_CustomEditorName;
|
||||||
public string m_FallbackName;
|
public string m_FallbackName;
|
||||||
public SerializedShaderDependency[] m_Dependencies;
|
public SerializedShaderDependency[] m_Dependencies;
|
||||||
|
public SerializedCustomEditorForRenderPipeline[] m_CustomEditorForRenderPipelines;
|
||||||
public bool m_DisableNoSubshadersMessage;
|
public bool m_DisableNoSubshadersMessage;
|
||||||
|
|
||||||
public SerializedShader(ObjectReader reader)
|
public SerializedShader(ObjectReader reader)
|
||||||
{
|
{
|
||||||
|
var version = reader.version;
|
||||||
|
|
||||||
m_PropInfo = new SerializedProperties(reader);
|
m_PropInfo = new SerializedProperties(reader);
|
||||||
|
|
||||||
int numSubShaders = reader.ReadInt32();
|
int numSubShaders = reader.ReadInt32();
|
||||||
@@ -702,6 +898,13 @@ namespace AssetStudio
|
|||||||
m_SubShaders[i] = new SerializedSubShader(reader);
|
m_SubShaders[i] = new SerializedSubShader(reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (version[0] > 2021 || (version[0] == 2021 && version[1] >= 2)) //2021.2 and up
|
||||||
|
{
|
||||||
|
m_KeywordNames = reader.ReadStringArray();
|
||||||
|
m_KeywordFlags = reader.ReadUInt8Array();
|
||||||
|
reader.AlignStream();
|
||||||
|
}
|
||||||
|
|
||||||
m_Name = reader.ReadAlignedString();
|
m_Name = reader.ReadAlignedString();
|
||||||
m_CustomEditorName = reader.ReadAlignedString();
|
m_CustomEditorName = reader.ReadAlignedString();
|
||||||
m_FallbackName = reader.ReadAlignedString();
|
m_FallbackName = reader.ReadAlignedString();
|
||||||
@@ -713,6 +916,16 @@ namespace AssetStudio
|
|||||||
m_Dependencies[i] = new SerializedShaderDependency(reader);
|
m_Dependencies[i] = new SerializedShaderDependency(reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (version[0] >= 2021) //2021.1 and up
|
||||||
|
{
|
||||||
|
int m_CustomEditorForRenderPipelinesSize = reader.ReadInt32();
|
||||||
|
m_CustomEditorForRenderPipelines = new SerializedCustomEditorForRenderPipeline[m_CustomEditorForRenderPipelinesSize];
|
||||||
|
for (int i = 0; i < m_CustomEditorForRenderPipelinesSize; i++)
|
||||||
|
{
|
||||||
|
m_CustomEditorForRenderPipelines[i] = new SerializedCustomEditorForRenderPipeline(reader);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_DisableNoSubshadersMessage = reader.ReadBoolean();
|
m_DisableNoSubshadersMessage = reader.ReadBoolean();
|
||||||
reader.AlignStream();
|
reader.AlignStream();
|
||||||
}
|
}
|
||||||
@@ -720,28 +933,32 @@ namespace AssetStudio
|
|||||||
|
|
||||||
public enum ShaderCompilerPlatform
|
public enum ShaderCompilerPlatform
|
||||||
{
|
{
|
||||||
kShaderCompPlatformNone = -1,
|
None = -1,
|
||||||
kShaderCompPlatformGL = 0,
|
GL = 0,
|
||||||
kShaderCompPlatformD3D9 = 1,
|
D3D9 = 1,
|
||||||
kShaderCompPlatformXbox360 = 2,
|
Xbox360 = 2,
|
||||||
kShaderCompPlatformPS3 = 3,
|
PS3 = 3,
|
||||||
kShaderCompPlatformD3D11 = 4,
|
D3D11 = 4,
|
||||||
kShaderCompPlatformGLES20 = 5,
|
GLES20 = 5,
|
||||||
kShaderCompPlatformNaCl = 6,
|
NaCl = 6,
|
||||||
kShaderCompPlatformFlash = 7,
|
Flash = 7,
|
||||||
kShaderCompPlatformD3D11_9x = 8,
|
D3D11_9x = 8,
|
||||||
kShaderCompPlatformGLES3Plus = 9,
|
GLES3Plus = 9,
|
||||||
kShaderCompPlatformPSP2 = 10,
|
PSP2 = 10,
|
||||||
kShaderCompPlatformPS4 = 11,
|
PS4 = 11,
|
||||||
kShaderCompPlatformXboxOne = 12,
|
XboxOne = 12,
|
||||||
kShaderCompPlatformPSM = 13,
|
PSM = 13,
|
||||||
kShaderCompPlatformMetal = 14,
|
Metal = 14,
|
||||||
kShaderCompPlatformOpenGLCore = 15,
|
OpenGLCore = 15,
|
||||||
kShaderCompPlatformN3DS = 16,
|
N3DS = 16,
|
||||||
kShaderCompPlatformWiiU = 17,
|
WiiU = 17,
|
||||||
kShaderCompPlatformVulkan = 18,
|
Vulkan = 18,
|
||||||
kShaderCompPlatformSwitch = 19,
|
Switch = 19,
|
||||||
kShaderCompPlatformXboxOneD3D12 = 20
|
XboxOneD3D12 = 20,
|
||||||
|
GameCoreXboxOne = 21,
|
||||||
|
GameCoreScarlett = 22,
|
||||||
|
PS5 = 23,
|
||||||
|
PS5NGGC = 24
|
||||||
};
|
};
|
||||||
|
|
||||||
public class Shader : NamedObject
|
public class Shader : NamedObject
|
||||||
@@ -753,9 +970,9 @@ namespace AssetStudio
|
|||||||
//5.5 and up
|
//5.5 and up
|
||||||
public SerializedShader m_ParsedForm;
|
public SerializedShader m_ParsedForm;
|
||||||
public ShaderCompilerPlatform[] platforms;
|
public ShaderCompilerPlatform[] platforms;
|
||||||
public uint[] offsets;
|
public uint[][] offsets;
|
||||||
public uint[] compressedLengths;
|
public uint[][] compressedLengths;
|
||||||
public uint[] decompressedLengths;
|
public uint[][] decompressedLengths;
|
||||||
public byte[] compressedBlob;
|
public byte[] compressedBlob;
|
||||||
|
|
||||||
public Shader(ObjectReader reader) : base(reader)
|
public Shader(ObjectReader reader) : base(reader)
|
||||||
@@ -766,27 +983,47 @@ namespace AssetStudio
|
|||||||
platforms = reader.ReadUInt32Array().Select(x => (ShaderCompilerPlatform)x).ToArray();
|
platforms = reader.ReadUInt32Array().Select(x => (ShaderCompilerPlatform)x).ToArray();
|
||||||
if (version[0] > 2019 || (version[0] == 2019 && version[1] >= 3)) //2019.3 and up
|
if (version[0] > 2019 || (version[0] == 2019 && version[1] >= 3)) //2019.3 and up
|
||||||
{
|
{
|
||||||
offsets = reader.ReadUInt32ArrayArray().Select(x => x[0]).ToArray();
|
offsets = reader.ReadUInt32ArrayArray();
|
||||||
compressedLengths = reader.ReadUInt32ArrayArray().Select(x => x[0]).ToArray();
|
compressedLengths = reader.ReadUInt32ArrayArray();
|
||||||
decompressedLengths = reader.ReadUInt32ArrayArray().Select(x => x[0]).ToArray();
|
decompressedLengths = reader.ReadUInt32ArrayArray();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
offsets = reader.ReadUInt32Array();
|
offsets = reader.ReadUInt32Array().Select(x => new[] { x }).ToArray();
|
||||||
compressedLengths = reader.ReadUInt32Array();
|
compressedLengths = reader.ReadUInt32Array().Select(x => new[] { x }).ToArray();
|
||||||
decompressedLengths = reader.ReadUInt32Array();
|
decompressedLengths = reader.ReadUInt32Array().Select(x => new[] { x }).ToArray();
|
||||||
}
|
}
|
||||||
compressedBlob = reader.ReadBytes(reader.ReadInt32());
|
compressedBlob = reader.ReadUInt8Array();
|
||||||
|
reader.AlignStream();
|
||||||
|
|
||||||
|
var m_DependenciesCount = reader.ReadInt32();
|
||||||
|
for (int i = 0; i < m_DependenciesCount; i++)
|
||||||
|
{
|
||||||
|
new PPtr<Shader>(reader);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (version[0] >= 2018)
|
||||||
|
{
|
||||||
|
var m_NonModifiableTexturesCount = reader.ReadInt32();
|
||||||
|
for (int i = 0; i < m_NonModifiableTexturesCount; i++)
|
||||||
|
{
|
||||||
|
var first = reader.ReadAlignedString();
|
||||||
|
new PPtr<Texture>(reader);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var m_ShaderIsBaked = reader.ReadBoolean();
|
||||||
|
reader.AlignStream();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_Script = reader.ReadBytes(reader.ReadInt32());
|
m_Script = reader.ReadUInt8Array();
|
||||||
reader.AlignStream();
|
reader.AlignStream();
|
||||||
var m_PathName = reader.ReadAlignedString();
|
var m_PathName = reader.ReadAlignedString();
|
||||||
if (version[0] == 5 && version[1] >= 3) //5.3 - 5.4
|
if (version[0] == 5 && version[1] >= 3) //5.3 - 5.4
|
||||||
{
|
{
|
||||||
decompressedSize = reader.ReadUInt32();
|
decompressedSize = reader.ReadUInt32();
|
||||||
m_SubProgramBlob = reader.ReadBytes(reader.ReadInt32());
|
m_SubProgramBlob = reader.ReadUInt8Array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace AssetStudio
|
namespace AssetStudio
|
||||||
@@ -13,29 +12,29 @@ namespace AssetStudio
|
|||||||
public SecondarySpriteTexture(ObjectReader reader)
|
public SecondarySpriteTexture(ObjectReader reader)
|
||||||
{
|
{
|
||||||
texture = new PPtr<Texture2D>(reader);
|
texture = new PPtr<Texture2D>(reader);
|
||||||
name = reader.ReadStringToNull();
|
name = reader.ReadAlignedString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum SpritePackingRotation
|
public enum SpritePackingRotation
|
||||||
{
|
{
|
||||||
kSPRNone = 0,
|
None = 0,
|
||||||
kSPRFlipHorizontal = 1,
|
FlipHorizontal = 1,
|
||||||
kSPRFlipVertical = 2,
|
FlipVertical = 2,
|
||||||
kSPRRotate180 = 3,
|
Rotate180 = 3,
|
||||||
kSPRRotate90 = 4
|
Rotate90 = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
public enum SpritePackingMode
|
public enum SpritePackingMode
|
||||||
{
|
{
|
||||||
kSPMTight = 0,
|
Tight = 0,
|
||||||
kSPMRectangle
|
Rectangle
|
||||||
};
|
};
|
||||||
|
|
||||||
public enum SpriteMeshType
|
public enum SpriteMeshType
|
||||||
{
|
{
|
||||||
kSpriteMeshTypeFullRect,
|
FullRect,
|
||||||
kSpriteMeshTypeTight
|
Tight
|
||||||
};
|
};
|
||||||
|
|
||||||
public class SpriteSettings
|
public class SpriteSettings
|
||||||
@@ -88,7 +87,7 @@ namespace AssetStudio
|
|||||||
public ushort[] indices;
|
public ushort[] indices;
|
||||||
public Matrix4x4[] m_Bindpose;
|
public Matrix4x4[] m_Bindpose;
|
||||||
public BoneWeights4[] m_SourceSkin;
|
public BoneWeights4[] m_SourceSkin;
|
||||||
public RectangleF textureRect;
|
public Rectf textureRect;
|
||||||
public Vector2 textureRectOffset;
|
public Vector2 textureRectOffset;
|
||||||
public Vector2 atlasRectOffset;
|
public Vector2 atlasRectOffset;
|
||||||
public SpriteSettings settingsRaw;
|
public SpriteSettings settingsRaw;
|
||||||
@@ -124,7 +123,7 @@ namespace AssetStudio
|
|||||||
m_SubMeshes[i] = new SubMesh(reader);
|
m_SubMeshes[i] = new SubMesh(reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_IndexBuffer = reader.ReadBytes(reader.ReadInt32());
|
m_IndexBuffer = reader.ReadUInt8Array();
|
||||||
reader.AlignStream();
|
reader.AlignStream();
|
||||||
|
|
||||||
m_VertexData = new VertexData(reader);
|
m_VertexData = new VertexData(reader);
|
||||||
@@ -156,7 +155,7 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
textureRect = reader.ReadRectangleF();
|
textureRect = new Rectf(reader);
|
||||||
textureRectOffset = reader.ReadVector2();
|
textureRectOffset = reader.ReadVector2();
|
||||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 6)) //5.6 and up
|
if (version[0] > 5 || (version[0] == 5 && version[1] >= 6)) //5.6 and up
|
||||||
{
|
{
|
||||||
@@ -176,13 +175,36 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class Rectf
|
||||||
|
{
|
||||||
|
public float x;
|
||||||
|
public float y;
|
||||||
|
public float width;
|
||||||
|
public float height;
|
||||||
|
|
||||||
|
public Rectf(float x, float y, float w, float h) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
width = w;
|
||||||
|
height = h;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Rectf(BinaryReader reader)
|
||||||
|
{
|
||||||
|
x = reader.ReadSingle();
|
||||||
|
y = reader.ReadSingle();
|
||||||
|
width = reader.ReadSingle();
|
||||||
|
height = reader.ReadSingle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public sealed class Sprite : NamedObject
|
public sealed class Sprite : NamedObject
|
||||||
{
|
{
|
||||||
public RectangleF m_Rect;
|
public Rectf m_Rect;
|
||||||
public Vector2 m_Offset;
|
public Vector2 m_Offset;
|
||||||
public Vector4 m_Border;
|
public Vector4 m_Border;
|
||||||
public float m_PixelsToUnits;
|
public float m_PixelsToUnits;
|
||||||
public Vector2 m_Pivot;
|
public Vector2 m_Pivot = new Vector2(0.5f, 0.5f);
|
||||||
public uint m_Extrude;
|
public uint m_Extrude;
|
||||||
public bool m_IsPolygon;
|
public bool m_IsPolygon;
|
||||||
public KeyValuePair<Guid, long> m_RenderDataKey;
|
public KeyValuePair<Guid, long> m_RenderDataKey;
|
||||||
@@ -190,10 +212,11 @@ namespace AssetStudio
|
|||||||
public PPtr<SpriteAtlas> m_SpriteAtlas;
|
public PPtr<SpriteAtlas> m_SpriteAtlas;
|
||||||
public SpriteRenderData m_RD;
|
public SpriteRenderData m_RD;
|
||||||
public Vector2[][] m_PhysicsShape;
|
public Vector2[][] m_PhysicsShape;
|
||||||
|
public bool akSplitAlpha;
|
||||||
|
|
||||||
public Sprite(ObjectReader reader) : base(reader)
|
public Sprite(ObjectReader reader) : base(reader)
|
||||||
{
|
{
|
||||||
m_Rect = reader.ReadRectangleF();
|
m_Rect = new Rectf(reader);
|
||||||
m_Offset = reader.ReadVector2();
|
m_Offset = reader.ReadVector2();
|
||||||
if (version[0] > 4 || (version[0] == 4 && version[1] >= 5)) //4.5 and up
|
if (version[0] > 4 || (version[0] == 4 && version[1] >= 5)) //4.5 and up
|
||||||
{
|
{
|
||||||
@@ -239,6 +262,8 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
akSplitAlpha = false;
|
||||||
|
|
||||||
//vector m_Bones 2018 and up
|
//vector m_Bones 2018 and up
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,19 +7,20 @@ namespace AssetStudio
|
|||||||
{
|
{
|
||||||
public PPtr<Texture2D> texture;
|
public PPtr<Texture2D> texture;
|
||||||
public PPtr<Texture2D> alphaTexture;
|
public PPtr<Texture2D> alphaTexture;
|
||||||
public System.Drawing.RectangleF textureRect;
|
public Rectf textureRect;
|
||||||
public Vector2 textureRectOffset;
|
public Vector2 textureRectOffset;
|
||||||
public Vector2 atlasRectOffset;
|
public Vector2 atlasRectOffset;
|
||||||
public Vector4 uvTransform;
|
public Vector4 uvTransform;
|
||||||
public float downscaleMultiplier;
|
public float downscaleMultiplier;
|
||||||
public SpriteSettings settingsRaw;
|
public SpriteSettings settingsRaw;
|
||||||
|
public SecondarySpriteTexture[] secondaryTextures;
|
||||||
|
|
||||||
public SpriteAtlasData(ObjectReader reader)
|
public SpriteAtlasData(ObjectReader reader)
|
||||||
{
|
{
|
||||||
var version = reader.version;
|
var version = reader.version;
|
||||||
texture = new PPtr<Texture2D>(reader);
|
texture = new PPtr<Texture2D>(reader);
|
||||||
alphaTexture = new PPtr<Texture2D>(reader);
|
alphaTexture = new PPtr<Texture2D>(reader);
|
||||||
textureRect = reader.ReadRectangleF();
|
textureRect = new Rectf(reader);
|
||||||
textureRectOffset = reader.ReadVector2();
|
textureRectOffset = reader.ReadVector2();
|
||||||
if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 2)) //2017.2 and up
|
if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 2)) //2017.2 and up
|
||||||
{
|
{
|
||||||
@@ -28,6 +29,16 @@ namespace AssetStudio
|
|||||||
uvTransform = reader.ReadVector4();
|
uvTransform = reader.ReadVector4();
|
||||||
downscaleMultiplier = reader.ReadSingle();
|
downscaleMultiplier = reader.ReadSingle();
|
||||||
settingsRaw = new SpriteSettings(reader);
|
settingsRaw = new SpriteSettings(reader);
|
||||||
|
if (version[0] > 2020 || (version[0] == 2020 && version[1] >= 2)) //2020.2 and up
|
||||||
|
{
|
||||||
|
var secondaryTexturesSize = reader.ReadInt32();
|
||||||
|
secondaryTextures = new SecondarySpriteTexture[secondaryTexturesSize];
|
||||||
|
for (int i = 0; i < secondaryTexturesSize; i++)
|
||||||
|
{
|
||||||
|
secondaryTextures[i] = new SecondarySpriteTexture(reader);
|
||||||
|
}
|
||||||
|
reader.AlignStream();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,6 +46,7 @@ namespace AssetStudio
|
|||||||
{
|
{
|
||||||
public PPtr<Sprite>[] m_PackedSprites;
|
public PPtr<Sprite>[] m_PackedSprites;
|
||||||
public Dictionary<KeyValuePair<Guid, long>, SpriteAtlasData> m_RenderDataMap;
|
public Dictionary<KeyValuePair<Guid, long>, SpriteAtlasData> m_RenderDataMap;
|
||||||
|
public bool m_IsVariant;
|
||||||
|
|
||||||
public SpriteAtlas(ObjectReader reader) : base(reader)
|
public SpriteAtlas(ObjectReader reader) : base(reader)
|
||||||
{
|
{
|
||||||
@@ -56,8 +68,9 @@ namespace AssetStudio
|
|||||||
var value = new SpriteAtlasData(reader);
|
var value = new SpriteAtlasData(reader);
|
||||||
m_RenderDataMap.Add(new KeyValuePair<Guid, long>(first, second), value);
|
m_RenderDataMap.Add(new KeyValuePair<Guid, long>(first, second), value);
|
||||||
}
|
}
|
||||||
//string m_Tag
|
var m_Tag = reader.ReadAlignedString();
|
||||||
//bool m_IsVariant
|
m_IsVariant = reader.ReadBoolean();
|
||||||
|
reader.AlignStream();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace AssetStudio
|
|||||||
|
|
||||||
public TextAsset(ObjectReader reader) : base(reader)
|
public TextAsset(ObjectReader reader) : base(reader)
|
||||||
{
|
{
|
||||||
m_Script = reader.ReadBytes(reader.ReadInt32());
|
m_Script = reader.ReadUInt8Array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,10 @@ namespace AssetStudio
|
|||||||
{
|
{
|
||||||
var m_ForcedFallbackFormat = reader.ReadInt32();
|
var m_ForcedFallbackFormat = reader.ReadInt32();
|
||||||
var m_DownscaleFallback = reader.ReadBoolean();
|
var m_DownscaleFallback = reader.ReadBoolean();
|
||||||
|
if (version[0] > 2020 || (version[0] == 2020 && version[1] >= 2)) //2020.2 and up
|
||||||
|
{
|
||||||
|
var m_IsAlphaChannelOptional = reader.ReadBoolean();
|
||||||
|
}
|
||||||
reader.AlignStream();
|
reader.AlignStream();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,13 +4,22 @@ namespace AssetStudio
|
|||||||
{
|
{
|
||||||
public class StreamingInfo
|
public class StreamingInfo
|
||||||
{
|
{
|
||||||
public uint offset;
|
public long offset; //ulong
|
||||||
public uint size;
|
public uint size;
|
||||||
public string path;
|
public string path;
|
||||||
|
|
||||||
public StreamingInfo(ObjectReader reader)
|
public StreamingInfo(ObjectReader reader)
|
||||||
{
|
{
|
||||||
offset = reader.ReadUInt32();
|
var version = reader.version;
|
||||||
|
|
||||||
|
if (version[0] >= 2020) //2020.1 and up
|
||||||
|
{
|
||||||
|
offset = reader.ReadInt64();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
offset = reader.ReadUInt32();
|
||||||
|
}
|
||||||
size = reader.ReadUInt32();
|
size = reader.ReadUInt32();
|
||||||
path = reader.ReadAlignedString();
|
path = reader.ReadAlignedString();
|
||||||
}
|
}
|
||||||
@@ -59,6 +68,10 @@ namespace AssetStudio
|
|||||||
m_Width = reader.ReadInt32();
|
m_Width = reader.ReadInt32();
|
||||||
m_Height = reader.ReadInt32();
|
m_Height = reader.ReadInt32();
|
||||||
var m_CompleteImageSize = reader.ReadInt32();
|
var m_CompleteImageSize = reader.ReadInt32();
|
||||||
|
if (version[0] >= 2020) //2020.1 and up
|
||||||
|
{
|
||||||
|
var m_MipsStripped = reader.ReadInt32();
|
||||||
|
}
|
||||||
m_TextureFormat = (TextureFormat)reader.ReadInt32();
|
m_TextureFormat = (TextureFormat)reader.ReadInt32();
|
||||||
if (version[0] < 5 || (version[0] == 5 && version[1] < 2)) //5.2 down
|
if (version[0] < 5 || (version[0] == 5 && version[1] < 2)) //5.2 down
|
||||||
{
|
{
|
||||||
@@ -68,9 +81,41 @@ namespace AssetStudio
|
|||||||
{
|
{
|
||||||
m_MipCount = reader.ReadInt32();
|
m_MipCount = reader.ReadInt32();
|
||||||
}
|
}
|
||||||
var m_IsReadable = reader.ReadBoolean(); //2.6.0 and up
|
if (version[0] > 2 || (version[0] == 2 && version[1] >= 6)) //2.6.0 and up
|
||||||
var m_ReadAllowed = reader.ReadBoolean(); //3.0.0 - 5.4
|
{
|
||||||
//bool m_StreamingMipmaps 2018.2 and up
|
var m_IsReadable = reader.ReadBoolean();
|
||||||
|
}
|
||||||
|
if (version[0] >= 2020) //2020.1 and up
|
||||||
|
{
|
||||||
|
var m_IsPreProcessed = reader.ReadBoolean();
|
||||||
|
}
|
||||||
|
if (version[0] > 2019 || (version[0] == 2019 && version[1] >= 3)) //2019.3 and up
|
||||||
|
{
|
||||||
|
if (version[0] > 2022 || (version[0] == 2022 && version[1] >= 2)) //2022.2 and up
|
||||||
|
{
|
||||||
|
var m_IgnoreMipmapLimit = reader.ReadBoolean();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var m_IgnoreMasterTextureLimit = reader.ReadBoolean();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (version[0] >= 3) //3.0.0 - 5.4
|
||||||
|
{
|
||||||
|
if (version[0] < 5 || (version[0] == 5 && version[1] <= 4))
|
||||||
|
{
|
||||||
|
var m_ReadAllowed = reader.ReadBoolean();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (version[0] > 2022 || (version[0] == 2022 && version[1] >= 2)) //2022.2 and up
|
||||||
|
{
|
||||||
|
var m_MipmapLimitGroupName = reader.ReadAlignedString();
|
||||||
|
reader.AlignStream();
|
||||||
|
}
|
||||||
|
if (version[0] > 2018 || (version[0] == 2018 && version[1] >= 2)) //2018.2 and up
|
||||||
|
{
|
||||||
|
var m_StreamingMipmaps = reader.ReadBoolean();
|
||||||
|
}
|
||||||
reader.AlignStream();
|
reader.AlignStream();
|
||||||
if (version[0] > 2018 || (version[0] == 2018 && version[1] >= 2)) //2018.2 and up
|
if (version[0] > 2018 || (version[0] == 2018 && version[1] >= 2)) //2018.2 and up
|
||||||
{
|
{
|
||||||
@@ -87,6 +132,11 @@ namespace AssetStudio
|
|||||||
{
|
{
|
||||||
var m_ColorSpace = reader.ReadInt32();
|
var m_ColorSpace = reader.ReadInt32();
|
||||||
}
|
}
|
||||||
|
if (version[0] > 2020 || (version[0] == 2020 && version[1] >= 2)) //2020.2 and up
|
||||||
|
{
|
||||||
|
var m_PlatformBlob = reader.ReadUInt8Array();
|
||||||
|
reader.AlignStream();
|
||||||
|
}
|
||||||
var image_data_size = reader.ReadInt32();
|
var image_data_size = reader.ReadInt32();
|
||||||
if (image_data_size == 0 && ((version[0] == 5 && version[1] >= 3) || version[0] > 5))//5.3.0 and up
|
if (image_data_size == 0 && ((version[0] == 5 && version[1] >= 3) || version[0] > 5))//5.3.0 and up
|
||||||
{
|
{
|
||||||
@@ -96,7 +146,7 @@ namespace AssetStudio
|
|||||||
ResourceReader resourceReader;
|
ResourceReader resourceReader;
|
||||||
if (!string.IsNullOrEmpty(m_StreamData?.path))
|
if (!string.IsNullOrEmpty(m_StreamData?.path))
|
||||||
{
|
{
|
||||||
resourceReader = new ResourceReader(m_StreamData.path, assetsFile, m_StreamData.offset, (int)m_StreamData.size);
|
resourceReader = new ResourceReader(m_StreamData.path, assetsFile, m_StreamData.offset, m_StreamData.size);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -113,10 +163,13 @@ namespace AssetStudio
|
|||||||
RGB24,
|
RGB24,
|
||||||
RGBA32,
|
RGBA32,
|
||||||
ARGB32,
|
ARGB32,
|
||||||
RGB565 = 7,
|
ARGBFloat,
|
||||||
R16 = 9,
|
RGB565,
|
||||||
|
BGR24,
|
||||||
|
R16,
|
||||||
DXT1,
|
DXT1,
|
||||||
DXT5 = 12,
|
DXT3,
|
||||||
|
DXT5,
|
||||||
RGBA4444,
|
RGBA4444,
|
||||||
BGRA32,
|
BGRA32,
|
||||||
RHalf,
|
RHalf,
|
||||||
@@ -127,11 +180,12 @@ namespace AssetStudio
|
|||||||
RGBAFloat,
|
RGBAFloat,
|
||||||
YUY2,
|
YUY2,
|
||||||
RGB9e5Float,
|
RGB9e5Float,
|
||||||
BC4 = 26,
|
RGBFloat,
|
||||||
BC5,
|
BC6H,
|
||||||
BC6H = 24,
|
|
||||||
BC7,
|
BC7,
|
||||||
DXT1Crunched = 28,
|
BC4,
|
||||||
|
BC5,
|
||||||
|
DXT1Crunched,
|
||||||
DXT5Crunched,
|
DXT5Crunched,
|
||||||
PVRTC_RGB2,
|
PVRTC_RGB2,
|
||||||
PVRTC_RGBA2,
|
PVRTC_RGBA2,
|
||||||
@@ -171,5 +225,8 @@ namespace AssetStudio
|
|||||||
ASTC_HDR_8x8,
|
ASTC_HDR_8x8,
|
||||||
ASTC_HDR_10x10,
|
ASTC_HDR_10x10,
|
||||||
ASTC_HDR_12x12,
|
ASTC_HDR_12x12,
|
||||||
|
RG32,
|
||||||
|
RGB48,
|
||||||
|
RGBA64
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,51 +1,75 @@
|
|||||||
using System;
|
using System.IO;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace AssetStudio
|
namespace AssetStudio
|
||||||
{
|
{
|
||||||
|
public class StreamedResource
|
||||||
|
{
|
||||||
|
public string m_Source;
|
||||||
|
public long m_Offset; //ulong
|
||||||
|
public long m_Size; //ulong
|
||||||
|
|
||||||
|
public StreamedResource(BinaryReader reader)
|
||||||
|
{
|
||||||
|
m_Source = reader.ReadAlignedString();
|
||||||
|
m_Offset = reader.ReadInt64();
|
||||||
|
m_Size = reader.ReadInt64();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public sealed class VideoClip : NamedObject
|
public sealed class VideoClip : NamedObject
|
||||||
{
|
{
|
||||||
public ResourceReader m_VideoData;
|
public ResourceReader m_VideoData;
|
||||||
public string m_OriginalPath;
|
public string m_OriginalPath;
|
||||||
public string m_Source;
|
public StreamedResource m_ExternalResources;
|
||||||
public ulong m_Size;
|
public uint Width;
|
||||||
|
public uint Height;
|
||||||
|
public double m_FrameRate;
|
||||||
|
public int m_Format;
|
||||||
|
public bool m_HasSplitAlpha;
|
||||||
|
|
||||||
public VideoClip(ObjectReader reader) : base(reader)
|
public VideoClip(ObjectReader reader) : base(reader)
|
||||||
{
|
{
|
||||||
m_OriginalPath = reader.ReadAlignedString();
|
m_OriginalPath = reader.ReadAlignedString();
|
||||||
var m_ProxyWidth = reader.ReadUInt32();
|
var m_ProxyWidth = reader.ReadUInt32();
|
||||||
var m_ProxyHeight = reader.ReadUInt32();
|
var m_ProxyHeight = reader.ReadUInt32();
|
||||||
var Width = reader.ReadUInt32();
|
Width = reader.ReadUInt32();
|
||||||
var Height = reader.ReadUInt32();
|
Height = reader.ReadUInt32();
|
||||||
if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 2)) //2017.2 and up
|
if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 2)) //2017.2 and up
|
||||||
{
|
{
|
||||||
var m_PixelAspecRatioNum = reader.ReadUInt32();
|
var m_PixelAspecRatioNum = reader.ReadUInt32();
|
||||||
var m_PixelAspecRatioDen = reader.ReadUInt32();
|
var m_PixelAspecRatioDen = reader.ReadUInt32();
|
||||||
}
|
}
|
||||||
var m_FrameRate = reader.ReadDouble();
|
m_FrameRate = reader.ReadDouble();
|
||||||
var m_FrameCount = reader.ReadUInt64();
|
var m_FrameCount = reader.ReadUInt64();
|
||||||
var m_Format = reader.ReadInt32();
|
m_Format = reader.ReadInt32();
|
||||||
var m_AudioChannelCount = reader.ReadUInt16Array();
|
var m_AudioChannelCount = reader.ReadUInt16Array();
|
||||||
reader.AlignStream();
|
reader.AlignStream();
|
||||||
var m_AudioSampleRate = reader.ReadUInt32Array();
|
var m_AudioSampleRate = reader.ReadUInt32Array();
|
||||||
var m_AudioLanguage = reader.ReadStringArray();
|
var m_AudioLanguage = reader.ReadStringArray();
|
||||||
//StreamedResource m_ExternalResources
|
if (version[0] >= 2020) //2020.1 and up
|
||||||
m_Source = reader.ReadAlignedString();
|
{
|
||||||
var m_Offset = reader.ReadUInt64();
|
var m_VideoShadersSize = reader.ReadInt32();
|
||||||
m_Size = reader.ReadUInt64();
|
var m_VideoShaders = new PPtr<Shader>[m_VideoShadersSize];
|
||||||
var m_HasSplitAlpha = reader.ReadBoolean();
|
for (int i = 0; i < m_VideoShadersSize; i++)
|
||||||
|
{
|
||||||
|
m_VideoShaders[i] = new PPtr<Shader>(reader);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_ExternalResources = new StreamedResource(reader);
|
||||||
|
m_HasSplitAlpha = reader.ReadBoolean();
|
||||||
|
if (version[0] >= 2020) //2020.1 and up
|
||||||
|
{
|
||||||
|
var m_sRGB = reader.ReadBoolean();
|
||||||
|
}
|
||||||
|
|
||||||
ResourceReader resourceReader;
|
ResourceReader resourceReader;
|
||||||
if (!string.IsNullOrEmpty(m_Source))
|
if (!string.IsNullOrEmpty(m_ExternalResources.m_Source))
|
||||||
{
|
{
|
||||||
resourceReader = new ResourceReader(m_Source, assetsFile, (long)m_Offset, (int)m_Size);
|
resourceReader = new ResourceReader(m_ExternalResources.m_Source, assetsFile, m_ExternalResources.m_Offset, m_ExternalResources.m_Size);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
resourceReader = new ResourceReader(reader, reader.BaseStream.Position, (int)m_Size);
|
resourceReader = new ResourceReader(reader, reader.BaseStream.Position, m_ExternalResources.m_Size);
|
||||||
}
|
}
|
||||||
m_VideoData = resourceReader;
|
m_VideoData = resourceReader;
|
||||||
}
|
}
|
||||||
|
|||||||
49
AssetStudio/ColorConsole.cs
Normal file
49
AssetStudio/ColorConsole.cs
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace AssetStudio
|
||||||
|
{
|
||||||
|
// Represents set with 16 base colors using ANSI escape codes, which should be supported in most terminals
|
||||||
|
// (well, except for windows editions before windows 10)
|
||||||
|
public static class ColorConsole
|
||||||
|
{
|
||||||
|
public static readonly string
|
||||||
|
Black = "\u001b[30m",
|
||||||
|
Red = "\u001b[31m",
|
||||||
|
Green = "\u001b[32m",
|
||||||
|
Yellow = "\u001b[33m", //remapped to ~BrightWhite in Windows PowerShell 6
|
||||||
|
Blue = "\u001b[34m",
|
||||||
|
Magenta = "\u001b[35m", //remapped to ~Blue in Windows PowerShell 6
|
||||||
|
Cyan = "\u001b[36m",
|
||||||
|
White = "\u001b[37m",
|
||||||
|
BrightBlack = "\u001b[30;1m",
|
||||||
|
BrightRed = "\u001b[31;1m",
|
||||||
|
BrightGreen = "\u001b[32;1m",
|
||||||
|
BrightYellow = "\u001b[33;1m",
|
||||||
|
BrightBlue = "\u001b[34;1m",
|
||||||
|
BrightMagenta = "\u001b[35;1m",
|
||||||
|
BrightCyan = "\u001b[36;1m",
|
||||||
|
BrightWhite = "\u001b[37;1m";
|
||||||
|
private static readonly string Reset = "\u001b[0m";
|
||||||
|
|
||||||
|
public static string Color(this string str, string ansiColor)
|
||||||
|
{
|
||||||
|
if (!ColorConsoleHelper.isAnsiCodesSupported)
|
||||||
|
{
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $"{ansiColor}{str}{Reset}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AnsiCodesTest()
|
||||||
|
{
|
||||||
|
Console.WriteLine("ANSI escape codes test");
|
||||||
|
Console.WriteLine($"Supported: {ColorConsoleHelper.isAnsiCodesSupported}");
|
||||||
|
Console.WriteLine("\u001b[30m A \u001b[31m B \u001b[32m C \u001b[33m D \u001b[0m");
|
||||||
|
Console.WriteLine("\u001b[34m E \u001b[35m F \u001b[36m G \u001b[37m H \u001b[0m");
|
||||||
|
Console.WriteLine("\u001b[30;1m A \u001b[31;1m B \u001b[32;1m C \u001b[33;1m D \u001b[0m");
|
||||||
|
Console.WriteLine("\u001b[34;1m E \u001b[35;1m F \u001b[36;1m G \u001b[37;1m H \u001b[0m");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
57
AssetStudio/ColorConsoleHelper.cs
Normal file
57
AssetStudio/ColorConsoleHelper.cs
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
// Based on code by tomzorz (https://gist.github.com/tomzorz/6142d69852f831fb5393654c90a1f22e)
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace AssetStudio
|
||||||
|
{
|
||||||
|
internal static class ColorConsoleHelper
|
||||||
|
{
|
||||||
|
public static readonly bool isAnsiCodesSupported;
|
||||||
|
private const int STD_OUTPUT_HANDLE = -11;
|
||||||
|
private const uint ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x0004;
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll")]
|
||||||
|
private static extern bool GetConsoleMode(IntPtr hConsoleHandle, out uint lpMode);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll")]
|
||||||
|
private static extern bool SetConsoleMode(IntPtr hConsoleHandle, uint dwMode);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll")]
|
||||||
|
private static extern IntPtr GetStdHandle(int nStdHandle);
|
||||||
|
|
||||||
|
static ColorConsoleHelper()
|
||||||
|
{
|
||||||
|
var isWin = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
|
||||||
|
if (isWin)
|
||||||
|
{
|
||||||
|
isAnsiCodesSupported = TryEnableVTMode();
|
||||||
|
if (!isAnsiCodesSupported)
|
||||||
|
{
|
||||||
|
//Check for bash terminal emulator. E.g., Git Bash, Cmder
|
||||||
|
isAnsiCodesSupported = Environment.GetEnvironmentVariable("TERM") != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
isAnsiCodesSupported = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable support for ANSI escape codes
|
||||||
|
// (but probably only suitable for windows 10+)
|
||||||
|
// https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences
|
||||||
|
private static bool TryEnableVTMode()
|
||||||
|
{
|
||||||
|
var iStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
|
||||||
|
if (!GetConsoleMode(iStdOut, out uint outConsoleMode))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
outConsoleMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
|
||||||
|
|
||||||
|
return SetConsoleMode(iStdOut, outConsoleMode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -113,7 +113,8 @@ namespace AssetStudio
|
|||||||
{1093, "m_CorrespondingSourceObject"},
|
{1093, "m_CorrespondingSourceObject"},
|
||||||
{1121, "m_PrefabInstance"},
|
{1121, "m_PrefabInstance"},
|
||||||
{1138, "m_PrefabAsset"},
|
{1138, "m_PrefabAsset"},
|
||||||
{1152, "FileSize"}
|
{1152, "FileSize"},
|
||||||
|
{1161, "Hash128"}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,19 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Buffers.Binary;
|
||||||
using System.Text;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace AssetStudio
|
namespace AssetStudio
|
||||||
{
|
{
|
||||||
public enum EndianType
|
|
||||||
{
|
|
||||||
LittleEndian,
|
|
||||||
BigEndian
|
|
||||||
}
|
|
||||||
|
|
||||||
public class EndianBinaryReader : BinaryReader
|
public class EndianBinaryReader : BinaryReader
|
||||||
{
|
{
|
||||||
public EndianType endian;
|
private readonly byte[] buffer;
|
||||||
|
|
||||||
|
public EndianType Endian;
|
||||||
|
|
||||||
public EndianBinaryReader(Stream stream, EndianType endian = EndianType.BigEndian) : base(stream)
|
public EndianBinaryReader(Stream stream, EndianType endian = EndianType.BigEndian) : base(stream)
|
||||||
{
|
{
|
||||||
this.endian = endian;
|
Endian = endian;
|
||||||
|
buffer = new byte[8];
|
||||||
}
|
}
|
||||||
|
|
||||||
public long Position
|
public long Position
|
||||||
@@ -28,88 +24,82 @@ namespace AssetStudio
|
|||||||
|
|
||||||
public override short ReadInt16()
|
public override short ReadInt16()
|
||||||
{
|
{
|
||||||
if (endian == EndianType.BigEndian)
|
if (Endian == EndianType.BigEndian)
|
||||||
{
|
{
|
||||||
var buff = ReadBytes(2);
|
Read(buffer, 0, 2);
|
||||||
Array.Reverse(buff);
|
return BinaryPrimitives.ReadInt16BigEndian(buffer);
|
||||||
return BitConverter.ToInt16(buff, 0);
|
|
||||||
}
|
}
|
||||||
return base.ReadInt16();
|
return base.ReadInt16();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int ReadInt32()
|
public override int ReadInt32()
|
||||||
{
|
{
|
||||||
if (endian == EndianType.BigEndian)
|
if (Endian == EndianType.BigEndian)
|
||||||
{
|
{
|
||||||
var buff = ReadBytes(4);
|
Read(buffer, 0, 4);
|
||||||
Array.Reverse(buff);
|
return BinaryPrimitives.ReadInt32BigEndian(buffer);
|
||||||
return BitConverter.ToInt32(buff, 0);
|
|
||||||
}
|
}
|
||||||
return base.ReadInt32();
|
return base.ReadInt32();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override long ReadInt64()
|
public override long ReadInt64()
|
||||||
{
|
{
|
||||||
if (endian == EndianType.BigEndian)
|
if (Endian == EndianType.BigEndian)
|
||||||
{
|
{
|
||||||
var buff = ReadBytes(8);
|
Read(buffer, 0, 8);
|
||||||
Array.Reverse(buff);
|
return BinaryPrimitives.ReadInt64BigEndian(buffer);
|
||||||
return BitConverter.ToInt64(buff, 0);
|
|
||||||
}
|
}
|
||||||
return base.ReadInt64();
|
return base.ReadInt64();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ushort ReadUInt16()
|
public override ushort ReadUInt16()
|
||||||
{
|
{
|
||||||
if (endian == EndianType.BigEndian)
|
if (Endian == EndianType.BigEndian)
|
||||||
{
|
{
|
||||||
var buff = ReadBytes(2);
|
Read(buffer, 0, 2);
|
||||||
Array.Reverse(buff);
|
return BinaryPrimitives.ReadUInt16BigEndian(buffer);
|
||||||
return BitConverter.ToUInt16(buff, 0);
|
|
||||||
}
|
}
|
||||||
return base.ReadUInt16();
|
return base.ReadUInt16();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override uint ReadUInt32()
|
public override uint ReadUInt32()
|
||||||
{
|
{
|
||||||
if (endian == EndianType.BigEndian)
|
if (Endian == EndianType.BigEndian)
|
||||||
{
|
{
|
||||||
var buff = ReadBytes(4);
|
Read(buffer, 0, 4);
|
||||||
Array.Reverse(buff);
|
return BinaryPrimitives.ReadUInt32BigEndian(buffer);
|
||||||
return BitConverter.ToUInt32(buff, 0);
|
|
||||||
}
|
}
|
||||||
return base.ReadUInt32();
|
return base.ReadUInt32();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ulong ReadUInt64()
|
public override ulong ReadUInt64()
|
||||||
{
|
{
|
||||||
if (endian == EndianType.BigEndian)
|
if (Endian == EndianType.BigEndian)
|
||||||
{
|
{
|
||||||
var buff = ReadBytes(8);
|
Read(buffer, 0, 8);
|
||||||
Array.Reverse(buff);
|
return BinaryPrimitives.ReadUInt64BigEndian(buffer);
|
||||||
return BitConverter.ToUInt64(buff, 0);
|
|
||||||
}
|
}
|
||||||
return base.ReadUInt64();
|
return base.ReadUInt64();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override float ReadSingle()
|
public override float ReadSingle()
|
||||||
{
|
{
|
||||||
if (endian == EndianType.BigEndian)
|
if (Endian == EndianType.BigEndian)
|
||||||
{
|
{
|
||||||
var buff = ReadBytes(4);
|
Read(buffer, 0, 4);
|
||||||
Array.Reverse(buff);
|
Array.Reverse(buffer, 0, 4);
|
||||||
return BitConverter.ToSingle(buff, 0);
|
return BitConverter.ToSingle(buffer, 0);
|
||||||
}
|
}
|
||||||
return base.ReadSingle();
|
return base.ReadSingle();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override double ReadDouble()
|
public override double ReadDouble()
|
||||||
{
|
{
|
||||||
if (endian == EndianType.BigEndian)
|
if (Endian == EndianType.BigEndian)
|
||||||
{
|
{
|
||||||
var buff = ReadBytes(8);
|
Read(buffer, 0, 8);
|
||||||
Array.Reverse(buff);
|
Array.Reverse(buffer);
|
||||||
return BitConverter.ToUInt64(buff, 0);
|
return BitConverter.ToDouble(buffer, 0);
|
||||||
}
|
}
|
||||||
return base.ReadDouble();
|
return base.ReadDouble();
|
||||||
}
|
}
|
||||||
|
|||||||
14
AssetStudio/EndianType.cs
Normal file
14
AssetStudio/EndianType.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AssetStudio
|
||||||
|
{
|
||||||
|
public enum EndianType
|
||||||
|
{
|
||||||
|
LittleEndian,
|
||||||
|
BigEndian
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -35,10 +35,13 @@ namespace AssetStudio
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string ReadStringToNull(this BinaryReader reader, int maxLength = 32767)
|
public static string ReadStringToNull(this BinaryReader reader, int maxLength = 32767, Encoding encoding = null)
|
||||||
{
|
{
|
||||||
|
if (encoding?.CodePage == 1200) //Unicode (UTF-16LE)
|
||||||
|
return reader.ReadUnicodeStringToNull(maxLength * 2);
|
||||||
|
|
||||||
var bytes = new List<byte>();
|
var bytes = new List<byte>();
|
||||||
int count = 0;
|
var count = 0;
|
||||||
while (reader.BaseStream.Position != reader.BaseStream.Length && count < maxLength)
|
while (reader.BaseStream.Position != reader.BaseStream.Length && count < maxLength)
|
||||||
{
|
{
|
||||||
var b = reader.ReadByte();
|
var b = reader.ReadByte();
|
||||||
@@ -49,7 +52,24 @@ namespace AssetStudio
|
|||||||
bytes.Add(b);
|
bytes.Add(b);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
return Encoding.UTF8.GetString(bytes.ToArray());
|
return encoding?.GetString(bytes.ToArray()) ?? Encoding.UTF8.GetString(bytes.ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string ReadUnicodeStringToNull(this BinaryReader reader, int maxLength)
|
||||||
|
{
|
||||||
|
var bytes = new List<byte>();
|
||||||
|
var count = 0;
|
||||||
|
while (reader.BaseStream.Position != reader.BaseStream.Length && count < maxLength)
|
||||||
|
{
|
||||||
|
var b = reader.ReadBytes(2);
|
||||||
|
if (b.Length < 2 || (b[0] == 0 && b[1] == 0))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
bytes.AddRange(b);
|
||||||
|
count += 2;
|
||||||
|
}
|
||||||
|
return Encoding.Unicode.GetString(bytes.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Quaternion ReadQuaternion(this BinaryReader reader)
|
public static Quaternion ReadQuaternion(this BinaryReader reader)
|
||||||
@@ -72,11 +92,6 @@ namespace AssetStudio
|
|||||||
return new Vector4(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
|
return new Vector4(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static System.Drawing.RectangleF ReadRectangleF(this BinaryReader reader)
|
|
||||||
{
|
|
||||||
return new System.Drawing.RectangleF(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Color ReadColor4(this BinaryReader reader)
|
public static Color ReadColor4(this BinaryReader reader)
|
||||||
{
|
{
|
||||||
return new Color(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
|
return new Color(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
|
||||||
@@ -102,6 +117,11 @@ namespace AssetStudio
|
|||||||
return ReadArray(reader.ReadBoolean, reader.ReadInt32());
|
return ReadArray(reader.ReadBoolean, reader.ReadInt32());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static byte[] ReadUInt8Array(this BinaryReader reader)
|
||||||
|
{
|
||||||
|
return reader.ReadBytes(reader.ReadInt32());
|
||||||
|
}
|
||||||
|
|
||||||
public static ushort[] ReadUInt16Array(this BinaryReader reader)
|
public static ushort[] ReadUInt16Array(this BinaryReader reader)
|
||||||
{
|
{
|
||||||
return ReadArray(reader.ReadUInt16, reader.ReadInt32());
|
return ReadArray(reader.ReadUInt16, reader.ReadInt32());
|
||||||
|
|||||||
103
AssetStudio/FileReader.cs
Normal file
103
AssetStudio/FileReader.cs
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace AssetStudio
|
||||||
|
{
|
||||||
|
public class FileReader : EndianBinaryReader
|
||||||
|
{
|
||||||
|
public string FullPath;
|
||||||
|
public string FileName;
|
||||||
|
public FileType FileType;
|
||||||
|
|
||||||
|
private static readonly byte[] gzipMagic = { 0x1f, 0x8b };
|
||||||
|
private static readonly byte[] brotliMagic = { 0x62, 0x72, 0x6F, 0x74, 0x6C, 0x69 };
|
||||||
|
private static readonly byte[] zipMagic = { 0x50, 0x4B, 0x03, 0x04 };
|
||||||
|
private static readonly byte[] zipSpannedMagic = { 0x50, 0x4B, 0x07, 0x08 };
|
||||||
|
|
||||||
|
public FileReader(string path) : this(path, File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { }
|
||||||
|
|
||||||
|
public FileReader(string path, Stream stream) : base(stream, EndianType.BigEndian)
|
||||||
|
{
|
||||||
|
FullPath = Path.GetFullPath(path);
|
||||||
|
FileName = Path.GetFileName(path);
|
||||||
|
FileType = CheckFileType();
|
||||||
|
}
|
||||||
|
|
||||||
|
private FileType CheckFileType()
|
||||||
|
{
|
||||||
|
var signature = this.ReadStringToNull(20);
|
||||||
|
Position = 0;
|
||||||
|
switch (signature)
|
||||||
|
{
|
||||||
|
case "UnityWeb":
|
||||||
|
case "UnityRaw":
|
||||||
|
case "UnityArchive":
|
||||||
|
case "UnityFS":
|
||||||
|
return FileType.BundleFile;
|
||||||
|
case "UnityWebData1.0":
|
||||||
|
return FileType.WebFile;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
byte[] magic = ReadBytes(2);
|
||||||
|
Position = 0;
|
||||||
|
if (gzipMagic.SequenceEqual(magic))
|
||||||
|
{
|
||||||
|
return FileType.GZipFile;
|
||||||
|
}
|
||||||
|
Position = 0x20;
|
||||||
|
magic = ReadBytes(6);
|
||||||
|
Position = 0;
|
||||||
|
if (brotliMagic.SequenceEqual(magic))
|
||||||
|
{
|
||||||
|
return FileType.BrotliFile;
|
||||||
|
}
|
||||||
|
if (IsSerializedFile())
|
||||||
|
{
|
||||||
|
return FileType.AssetsFile;
|
||||||
|
}
|
||||||
|
magic = ReadBytes(4);
|
||||||
|
Position = 0;
|
||||||
|
if (zipMagic.SequenceEqual(magic) || zipSpannedMagic.SequenceEqual(magic))
|
||||||
|
return FileType.ZipFile;
|
||||||
|
return FileType.ResourceFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsSerializedFile()
|
||||||
|
{
|
||||||
|
var fileSize = BaseStream.Length;
|
||||||
|
if (fileSize < 20)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var m_MetadataSize = ReadUInt32();
|
||||||
|
long m_FileSize = ReadUInt32();
|
||||||
|
var m_Version = ReadUInt32();
|
||||||
|
long m_DataOffset = ReadUInt32();
|
||||||
|
var m_Endianess = ReadByte();
|
||||||
|
var m_Reserved = ReadBytes(3);
|
||||||
|
if (m_Version >= 22)
|
||||||
|
{
|
||||||
|
if (fileSize < 48)
|
||||||
|
{
|
||||||
|
Position = 0;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
m_MetadataSize = ReadUInt32();
|
||||||
|
m_FileSize = ReadInt64();
|
||||||
|
m_DataOffset = ReadInt64();
|
||||||
|
}
|
||||||
|
Position = 0;
|
||||||
|
if (m_FileSize != fileSize)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (m_DataOffset > fileSize)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
19
AssetStudio/FileType.cs
Normal file
19
AssetStudio/FileType.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AssetStudio
|
||||||
|
{
|
||||||
|
public enum FileType
|
||||||
|
{
|
||||||
|
AssetsFile,
|
||||||
|
BundleFile,
|
||||||
|
WebFile,
|
||||||
|
ResourceFile,
|
||||||
|
GZipFile,
|
||||||
|
BrotliFile,
|
||||||
|
ZipFile
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -73,6 +73,28 @@ namespace AssetStudio
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ImportedFrame FindRelativeFrameWithPath(string path)
|
||||||
|
{
|
||||||
|
var subs = path.Split(new[] { '/' }, 2);
|
||||||
|
foreach (var child in children)
|
||||||
|
{
|
||||||
|
if (child.Name == subs[0])
|
||||||
|
{
|
||||||
|
if (subs.Length == 1)
|
||||||
|
{
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var result = child.FindRelativeFrameWithPath(subs[1]);
|
||||||
|
if (result != null)
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public ImportedFrame FindFrame(string name)
|
public ImportedFrame FindFrame(string name)
|
||||||
{
|
{
|
||||||
if (Name == name)
|
if (Name == name)
|
||||||
@@ -132,6 +154,7 @@ namespace AssetStudio
|
|||||||
public class ImportedMesh
|
public class ImportedMesh
|
||||||
{
|
{
|
||||||
public string Path { get; set; }
|
public string Path { get; set; }
|
||||||
|
public List<ImportedVertex> VertexList { get; set; }
|
||||||
public List<ImportedSubmesh> SubmeshList { get; set; }
|
public List<ImportedSubmesh> SubmeshList { get; set; }
|
||||||
public List<ImportedBone> BoneList { get; set; }
|
public List<ImportedBone> BoneList { get; set; }
|
||||||
public bool hasNormal { get; set; }
|
public bool hasNormal { get; set; }
|
||||||
@@ -142,9 +165,9 @@ namespace AssetStudio
|
|||||||
|
|
||||||
public class ImportedSubmesh
|
public class ImportedSubmesh
|
||||||
{
|
{
|
||||||
public List<ImportedVertex> VertexList { get; set; }
|
|
||||||
public List<ImportedFace> FaceList { get; set; }
|
public List<ImportedFace> FaceList { get; set; }
|
||||||
public string Material { get; set; }
|
public string Material { get; set; }
|
||||||
|
public int BaseVertex { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ImportedVertex
|
public class ImportedVertex
|
||||||
|
|||||||
@@ -16,11 +16,11 @@ namespace AssetStudio
|
|||||||
|
|
||||||
public interface ILogger
|
public interface ILogger
|
||||||
{
|
{
|
||||||
void Log(LoggerEvent loggerEvent, string message);
|
void Log(LoggerEvent loggerEvent, string message, bool ignoreLevel = false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class DummyLogger : ILogger
|
public sealed class DummyLogger : ILogger
|
||||||
{
|
{
|
||||||
public void Log(LoggerEvent loggerEvent, string message) { }
|
public void Log(LoggerEvent loggerEvent, string message, bool ignoreLevel) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace AssetStudio
|
|
||||||
{
|
|
||||||
public interface IProgress
|
|
||||||
{
|
|
||||||
void Report(int value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public sealed class DummyProgress : IProgress
|
|
||||||
{
|
|
||||||
public void Report(int value) { }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +1,11 @@
|
|||||||
using System.Collections.Generic;
|
using Org.Brotli.Dec;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.IO.Compression;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace AssetStudio
|
namespace AssetStudio
|
||||||
{
|
{
|
||||||
public enum FileType
|
|
||||||
{
|
|
||||||
AssetsFile,
|
|
||||||
BundleFile,
|
|
||||||
WebFile,
|
|
||||||
ResourceFile
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class ImportHelper
|
public static class ImportHelper
|
||||||
{
|
{
|
||||||
public static void MergeSplitAssets(string path, bool allDirectories = false)
|
public static void MergeSplitAssets(string path, bool allDirectories = false)
|
||||||
@@ -20,8 +14,8 @@ namespace AssetStudio
|
|||||||
foreach (var splitFile in splitFiles)
|
foreach (var splitFile in splitFiles)
|
||||||
{
|
{
|
||||||
var destFile = Path.GetFileNameWithoutExtension(splitFile);
|
var destFile = Path.GetFileNameWithoutExtension(splitFile);
|
||||||
var destPath = Path.GetDirectoryName(splitFile) + "\\";
|
var destPath = Path.GetDirectoryName(splitFile);
|
||||||
var destFull = destPath + destFile;
|
var destFull = Path.Combine(destPath, destFile);
|
||||||
if (!File.Exists(destFull))
|
if (!File.Exists(destFull))
|
||||||
{
|
{
|
||||||
var splitParts = Directory.GetFiles(destPath, destFile + ".split*");
|
var splitParts = Directory.GetFiles(destPath, destFile + ".split*");
|
||||||
@@ -43,7 +37,7 @@ namespace AssetStudio
|
|||||||
public static string[] ProcessingSplitFiles(List<string> selectFile)
|
public static string[] ProcessingSplitFiles(List<string> selectFile)
|
||||||
{
|
{
|
||||||
var splitFiles = selectFile.Where(x => x.Contains(".split"))
|
var splitFiles = selectFile.Where(x => x.Contains(".split"))
|
||||||
.Select(x => Path.GetDirectoryName(x) + "\\" + Path.GetFileNameWithoutExtension(x))
|
.Select(x => Path.Combine(Path.GetDirectoryName(x), Path.GetFileNameWithoutExtension(x)))
|
||||||
.Distinct()
|
.Distinct()
|
||||||
.ToList();
|
.ToList();
|
||||||
selectFile.RemoveAll(x => x.Contains(".split"));
|
selectFile.RemoveAll(x => x.Contains(".split"));
|
||||||
@@ -57,55 +51,40 @@ namespace AssetStudio
|
|||||||
return selectFile.Distinct().ToArray();
|
return selectFile.Distinct().ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FileType CheckFileType(Stream stream, out EndianBinaryReader reader)
|
public static FileReader DecompressGZip(FileReader reader)
|
||||||
{
|
{
|
||||||
reader = new EndianBinaryReader(stream);
|
try
|
||||||
return CheckFileType(reader);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FileType CheckFileType(string fileName, out EndianBinaryReader reader)
|
|
||||||
{
|
|
||||||
reader = new EndianBinaryReader(File.OpenRead(fileName));
|
|
||||||
return CheckFileType(reader);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static FileType CheckFileType(EndianBinaryReader reader)
|
|
||||||
{
|
|
||||||
var signature = reader.ReadStringToNull(20);
|
|
||||||
reader.Position = 0;
|
|
||||||
switch (signature)
|
|
||||||
{
|
{
|
||||||
case "UnityWeb":
|
using (reader)
|
||||||
case "UnityRaw":
|
{
|
||||||
case "UnityArchive":
|
var stream = new MemoryStream();
|
||||||
case "UnityFS":
|
using (var gs = new GZipStream(reader.BaseStream, CompressionMode.Decompress))
|
||||||
return FileType.BundleFile;
|
|
||||||
case "UnityWebData1.0":
|
|
||||||
return FileType.WebFile;
|
|
||||||
default:
|
|
||||||
{
|
{
|
||||||
var magic = reader.ReadBytes(2);
|
gs.CopyTo(stream);
|
||||||
reader.Position = 0;
|
|
||||||
if (WebFile.gzipMagic.SequenceEqual(magic))
|
|
||||||
{
|
|
||||||
return FileType.WebFile;
|
|
||||||
}
|
|
||||||
reader.Position = 0x20;
|
|
||||||
magic = reader.ReadBytes(6);
|
|
||||||
reader.Position = 0;
|
|
||||||
if (WebFile.brotliMagic.SequenceEqual(magic))
|
|
||||||
{
|
|
||||||
return FileType.WebFile;
|
|
||||||
}
|
|
||||||
if (SerializedFile.IsSerializedFile(reader))
|
|
||||||
{
|
|
||||||
return FileType.AssetsFile;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return FileType.ResourceFile;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
stream.Position = 0;
|
||||||
|
return new FileReader(reader.FullPath, stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
Logger.Warning($"Error while decompressing gzip file {reader.FullPath}\r\n{e}");
|
||||||
|
reader.Dispose();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FileReader DecompressBrotli(FileReader reader)
|
||||||
|
{
|
||||||
|
using (reader)
|
||||||
|
{
|
||||||
|
var stream = new MemoryStream();
|
||||||
|
using (var brotliStream = new BrotliInputStream(reader.BaseStream))
|
||||||
|
{
|
||||||
|
brotliStream.CopyTo(stream);
|
||||||
|
}
|
||||||
|
stream.Position = 0;
|
||||||
|
return new FileReader(reader.FullPath, stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,5 +14,14 @@ namespace AssetStudio
|
|||||||
public static void Info(string message) => Default.Log(LoggerEvent.Info, message);
|
public static void Info(string message) => Default.Log(LoggerEvent.Info, message);
|
||||||
public static void Warning(string message) => Default.Log(LoggerEvent.Warning, message);
|
public static void Warning(string message) => Default.Log(LoggerEvent.Warning, message);
|
||||||
public static void Error(string message) => Default.Log(LoggerEvent.Error, message);
|
public static void Error(string message) => Default.Log(LoggerEvent.Error, message);
|
||||||
|
|
||||||
|
public static void Error(string message, Exception e)
|
||||||
|
{
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
sb.AppendLine(message);
|
||||||
|
sb.AppendLine();
|
||||||
|
sb.AppendLine(e.ToString());
|
||||||
|
Default.Log(LoggerEvent.Error, sb.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,540 +0,0 @@
|
|||||||
#define CHECK_ARGS
|
|
||||||
#define CHECK_EOF
|
|
||||||
//#define LOCAL_SHADOW
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace Lz4
|
|
||||||
{
|
|
||||||
public class Lz4DecoderStream : Stream
|
|
||||||
{
|
|
||||||
public Lz4DecoderStream(Stream input, long inputLength = long.MaxValue)
|
|
||||||
{
|
|
||||||
Reset(input, inputLength);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Reset(Stream input, long inputLength = long.MaxValue)
|
|
||||||
{
|
|
||||||
this.inputLength = inputLength;
|
|
||||||
this.input = input;
|
|
||||||
|
|
||||||
phase = DecodePhase.ReadToken;
|
|
||||||
|
|
||||||
decodeBufferPos = 0;
|
|
||||||
|
|
||||||
litLen = 0;
|
|
||||||
matLen = 0;
|
|
||||||
matDst = 0;
|
|
||||||
|
|
||||||
inBufPos = DecBufLen;
|
|
||||||
inBufEnd = DecBufLen;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (disposing && input != null)
|
|
||||||
{
|
|
||||||
input.Close();
|
|
||||||
}
|
|
||||||
input = null;
|
|
||||||
decodeBuffer = null;
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private long inputLength;
|
|
||||||
private Stream input;
|
|
||||||
|
|
||||||
//because we might not be able to match back across invocations,
|
|
||||||
//we have to keep the last window's worth of bytes around for reuse
|
|
||||||
//we use a circular buffer for this - every time we write into this
|
|
||||||
//buffer, we also write the same into our output buffer
|
|
||||||
|
|
||||||
private const int DecBufLen = 0x10000;
|
|
||||||
private const int DecBufMask = 0xFFFF;
|
|
||||||
|
|
||||||
private const int InBufLen = 128;
|
|
||||||
|
|
||||||
private byte[] decodeBuffer = new byte[DecBufLen + InBufLen];
|
|
||||||
private int decodeBufferPos, inBufPos, inBufEnd;
|
|
||||||
|
|
||||||
//we keep track of which phase we're in so that we can jump right back
|
|
||||||
//into the correct part of decoding
|
|
||||||
|
|
||||||
private DecodePhase phase;
|
|
||||||
|
|
||||||
private enum DecodePhase
|
|
||||||
{
|
|
||||||
ReadToken,
|
|
||||||
ReadExLiteralLength,
|
|
||||||
CopyLiteral,
|
|
||||||
ReadOffset,
|
|
||||||
ReadExMatchLength,
|
|
||||||
CopyMatch,
|
|
||||||
}
|
|
||||||
|
|
||||||
//state within interruptable phases and across phase boundaries is
|
|
||||||
//kept here - again, so that we can punt out and restart freely
|
|
||||||
|
|
||||||
private int litLen, matLen, matDst;
|
|
||||||
|
|
||||||
public override int Read(byte[] buffer, int offset, int count)
|
|
||||||
{
|
|
||||||
#if CHECK_ARGS
|
|
||||||
if (buffer == null)
|
|
||||||
throw new ArgumentNullException("buffer");
|
|
||||||
if (offset < 0 || count < 0 || buffer.Length - count < offset)
|
|
||||||
throw new ArgumentOutOfRangeException();
|
|
||||||
|
|
||||||
if (input == null)
|
|
||||||
throw new InvalidOperationException();
|
|
||||||
#endif
|
|
||||||
int nRead, nToRead = count;
|
|
||||||
|
|
||||||
var decBuf = decodeBuffer;
|
|
||||||
|
|
||||||
//the stringy gotos are obnoxious, but their purpose is to
|
|
||||||
//make it *blindingly* obvious how the state machine transitions
|
|
||||||
//back and forth as it reads - remember, we can yield out of
|
|
||||||
//this routine in several places, and we must be able to re-enter
|
|
||||||
//and pick up where we left off!
|
|
||||||
|
|
||||||
#if LOCAL_SHADOW
|
|
||||||
var phase = this.phase;
|
|
||||||
var inBufPos = this.inBufPos;
|
|
||||||
var inBufEnd = this.inBufEnd;
|
|
||||||
#endif
|
|
||||||
switch (phase)
|
|
||||||
{
|
|
||||||
case DecodePhase.ReadToken:
|
|
||||||
goto readToken;
|
|
||||||
|
|
||||||
case DecodePhase.ReadExLiteralLength:
|
|
||||||
goto readExLiteralLength;
|
|
||||||
|
|
||||||
case DecodePhase.CopyLiteral:
|
|
||||||
goto copyLiteral;
|
|
||||||
|
|
||||||
case DecodePhase.ReadOffset:
|
|
||||||
goto readOffset;
|
|
||||||
|
|
||||||
case DecodePhase.ReadExMatchLength:
|
|
||||||
goto readExMatchLength;
|
|
||||||
|
|
||||||
case DecodePhase.CopyMatch:
|
|
||||||
goto copyMatch;
|
|
||||||
}
|
|
||||||
|
|
||||||
readToken:
|
|
||||||
int tok;
|
|
||||||
if (inBufPos < inBufEnd)
|
|
||||||
{
|
|
||||||
tok = decBuf[inBufPos++];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#if LOCAL_SHADOW
|
|
||||||
this.inBufPos = inBufPos;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
tok = ReadByteCore();
|
|
||||||
#if LOCAL_SHADOW
|
|
||||||
inBufPos = this.inBufPos;
|
|
||||||
inBufEnd = this.inBufEnd;
|
|
||||||
#endif
|
|
||||||
#if CHECK_EOF
|
|
||||||
if (tok == -1)
|
|
||||||
goto finish;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
litLen = tok >> 4;
|
|
||||||
matLen = (tok & 0xF) + 4;
|
|
||||||
|
|
||||||
switch (litLen)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
phase = DecodePhase.ReadOffset;
|
|
||||||
goto readOffset;
|
|
||||||
|
|
||||||
case 0xF:
|
|
||||||
phase = DecodePhase.ReadExLiteralLength;
|
|
||||||
goto readExLiteralLength;
|
|
||||||
|
|
||||||
default:
|
|
||||||
phase = DecodePhase.CopyLiteral;
|
|
||||||
goto copyLiteral;
|
|
||||||
}
|
|
||||||
|
|
||||||
readExLiteralLength:
|
|
||||||
int exLitLen;
|
|
||||||
if (inBufPos < inBufEnd)
|
|
||||||
{
|
|
||||||
exLitLen = decBuf[inBufPos++];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#if LOCAL_SHADOW
|
|
||||||
this.inBufPos = inBufPos;
|
|
||||||
#endif
|
|
||||||
exLitLen = ReadByteCore();
|
|
||||||
#if LOCAL_SHADOW
|
|
||||||
inBufPos = this.inBufPos;
|
|
||||||
inBufEnd = this.inBufEnd;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if CHECK_EOF
|
|
||||||
if (exLitLen == -1)
|
|
||||||
goto finish;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
litLen += exLitLen;
|
|
||||||
if (exLitLen == 255)
|
|
||||||
goto readExLiteralLength;
|
|
||||||
|
|
||||||
phase = DecodePhase.CopyLiteral;
|
|
||||||
goto copyLiteral;
|
|
||||||
|
|
||||||
copyLiteral:
|
|
||||||
int nReadLit = litLen < nToRead ? litLen : nToRead;
|
|
||||||
if (nReadLit != 0)
|
|
||||||
{
|
|
||||||
if (inBufPos + nReadLit <= inBufEnd)
|
|
||||||
{
|
|
||||||
int ofs = offset;
|
|
||||||
|
|
||||||
for (int c = nReadLit; c-- != 0;)
|
|
||||||
buffer[ofs++] = decBuf[inBufPos++];
|
|
||||||
|
|
||||||
nRead = nReadLit;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#if LOCAL_SHADOW
|
|
||||||
this.inBufPos = inBufPos;
|
|
||||||
#endif
|
|
||||||
nRead = ReadCore(buffer, offset, nReadLit);
|
|
||||||
#if LOCAL_SHADOW
|
|
||||||
inBufPos = this.inBufPos;
|
|
||||||
inBufEnd = this.inBufEnd;
|
|
||||||
#endif
|
|
||||||
#if CHECK_EOF
|
|
||||||
if (nRead == 0)
|
|
||||||
goto finish;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
offset += nRead;
|
|
||||||
nToRead -= nRead;
|
|
||||||
|
|
||||||
litLen -= nRead;
|
|
||||||
|
|
||||||
if (litLen != 0)
|
|
||||||
goto copyLiteral;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nToRead == 0)
|
|
||||||
goto finish;
|
|
||||||
|
|
||||||
phase = DecodePhase.ReadOffset;
|
|
||||||
goto readOffset;
|
|
||||||
|
|
||||||
readOffset:
|
|
||||||
if (inBufPos + 1 < inBufEnd)
|
|
||||||
{
|
|
||||||
matDst = (decBuf[inBufPos + 1] << 8) | decBuf[inBufPos];
|
|
||||||
inBufPos += 2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#if LOCAL_SHADOW
|
|
||||||
this.inBufPos = inBufPos;
|
|
||||||
#endif
|
|
||||||
matDst = ReadOffsetCore();
|
|
||||||
#if LOCAL_SHADOW
|
|
||||||
inBufPos = this.inBufPos;
|
|
||||||
inBufEnd = this.inBufEnd;
|
|
||||||
#endif
|
|
||||||
#if CHECK_EOF
|
|
||||||
if (matDst == -1)
|
|
||||||
goto finish;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
if (matLen == 15 + 4)
|
|
||||||
{
|
|
||||||
phase = DecodePhase.ReadExMatchLength;
|
|
||||||
goto readExMatchLength;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
phase = DecodePhase.CopyMatch;
|
|
||||||
goto copyMatch;
|
|
||||||
}
|
|
||||||
|
|
||||||
readExMatchLength:
|
|
||||||
int exMatLen;
|
|
||||||
if (inBufPos < inBufEnd)
|
|
||||||
{
|
|
||||||
exMatLen = decBuf[inBufPos++];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#if LOCAL_SHADOW
|
|
||||||
this.inBufPos = inBufPos;
|
|
||||||
#endif
|
|
||||||
exMatLen = ReadByteCore();
|
|
||||||
#if LOCAL_SHADOW
|
|
||||||
inBufPos = this.inBufPos;
|
|
||||||
inBufEnd = this.inBufEnd;
|
|
||||||
#endif
|
|
||||||
#if CHECK_EOF
|
|
||||||
if (exMatLen == -1)
|
|
||||||
goto finish;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
matLen += exMatLen;
|
|
||||||
if (exMatLen == 255)
|
|
||||||
goto readExMatchLength;
|
|
||||||
|
|
||||||
phase = DecodePhase.CopyMatch;
|
|
||||||
goto copyMatch;
|
|
||||||
|
|
||||||
copyMatch:
|
|
||||||
int nCpyMat = matLen < nToRead ? matLen : nToRead;
|
|
||||||
if (nCpyMat != 0)
|
|
||||||
{
|
|
||||||
nRead = count - nToRead;
|
|
||||||
|
|
||||||
int bufDst = matDst - nRead;
|
|
||||||
if (bufDst > 0)
|
|
||||||
{
|
|
||||||
//offset is fairly far back, we need to pull from the buffer
|
|
||||||
|
|
||||||
int bufSrc = decodeBufferPos - bufDst;
|
|
||||||
if (bufSrc < 0)
|
|
||||||
bufSrc += DecBufLen;
|
|
||||||
int bufCnt = bufDst < nCpyMat ? bufDst : nCpyMat;
|
|
||||||
|
|
||||||
for (int c = bufCnt; c-- != 0;)
|
|
||||||
buffer[offset++] = decBuf[bufSrc++ & DecBufMask];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bufDst = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int sOfs = offset - matDst;
|
|
||||||
for (int i = bufDst; i < nCpyMat; i++)
|
|
||||||
buffer[offset++] = buffer[sOfs++];
|
|
||||||
|
|
||||||
nToRead -= nCpyMat;
|
|
||||||
matLen -= nCpyMat;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nToRead == 0)
|
|
||||||
goto finish;
|
|
||||||
|
|
||||||
phase = DecodePhase.ReadToken;
|
|
||||||
goto readToken;
|
|
||||||
|
|
||||||
finish:
|
|
||||||
nRead = count - nToRead;
|
|
||||||
|
|
||||||
int nToBuf = nRead < DecBufLen ? nRead : DecBufLen;
|
|
||||||
int repPos = offset - nToBuf;
|
|
||||||
|
|
||||||
if (nToBuf == DecBufLen)
|
|
||||||
{
|
|
||||||
Buffer.BlockCopy(buffer, repPos, decBuf, 0, DecBufLen);
|
|
||||||
decodeBufferPos = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int decPos = decodeBufferPos;
|
|
||||||
|
|
||||||
while (nToBuf-- != 0)
|
|
||||||
decBuf[decPos++ & DecBufMask] = buffer[repPos++];
|
|
||||||
|
|
||||||
decodeBufferPos = decPos & DecBufMask;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if LOCAL_SHADOW
|
|
||||||
this.phase = phase;
|
|
||||||
this.inBufPos = inBufPos;
|
|
||||||
#endif
|
|
||||||
return nRead;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int ReadByteCore()
|
|
||||||
{
|
|
||||||
var buf = decodeBuffer;
|
|
||||||
|
|
||||||
if (inBufPos == inBufEnd)
|
|
||||||
{
|
|
||||||
int nRead = input.Read(buf, DecBufLen,
|
|
||||||
InBufLen < inputLength ? InBufLen : (int)inputLength);
|
|
||||||
|
|
||||||
#if CHECK_EOF
|
|
||||||
if (nRead == 0)
|
|
||||||
return -1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
inputLength -= nRead;
|
|
||||||
|
|
||||||
inBufPos = DecBufLen;
|
|
||||||
inBufEnd = DecBufLen + nRead;
|
|
||||||
}
|
|
||||||
|
|
||||||
return buf[inBufPos++];
|
|
||||||
}
|
|
||||||
|
|
||||||
private int ReadOffsetCore()
|
|
||||||
{
|
|
||||||
var buf = decodeBuffer;
|
|
||||||
|
|
||||||
if (inBufPos == inBufEnd)
|
|
||||||
{
|
|
||||||
int nRead = input.Read(buf, DecBufLen,
|
|
||||||
InBufLen < inputLength ? InBufLen : (int)inputLength);
|
|
||||||
|
|
||||||
#if CHECK_EOF
|
|
||||||
if (nRead == 0)
|
|
||||||
return -1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
inputLength -= nRead;
|
|
||||||
|
|
||||||
inBufPos = DecBufLen;
|
|
||||||
inBufEnd = DecBufLen + nRead;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inBufEnd - inBufPos == 1)
|
|
||||||
{
|
|
||||||
buf[DecBufLen] = buf[inBufPos];
|
|
||||||
|
|
||||||
int nRead = input.Read(buf, DecBufLen + 1,
|
|
||||||
InBufLen - 1 < inputLength ? InBufLen - 1 : (int)inputLength);
|
|
||||||
|
|
||||||
#if CHECK_EOF
|
|
||||||
if (nRead == 0)
|
|
||||||
{
|
|
||||||
inBufPos = DecBufLen;
|
|
||||||
inBufEnd = DecBufLen + 1;
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
inputLength -= nRead;
|
|
||||||
|
|
||||||
inBufPos = DecBufLen;
|
|
||||||
inBufEnd = DecBufLen + nRead + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ret = (buf[inBufPos + 1] << 8) | buf[inBufPos];
|
|
||||||
inBufPos += 2;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int ReadCore(byte[] buffer, int offset, int count)
|
|
||||||
{
|
|
||||||
int nToRead = count;
|
|
||||||
|
|
||||||
var buf = decodeBuffer;
|
|
||||||
int inBufLen = inBufEnd - inBufPos;
|
|
||||||
|
|
||||||
int fromBuf = nToRead < inBufLen ? nToRead : inBufLen;
|
|
||||||
if (fromBuf != 0)
|
|
||||||
{
|
|
||||||
var bufPos = inBufPos;
|
|
||||||
|
|
||||||
for (int c = fromBuf; c-- != 0;)
|
|
||||||
buffer[offset++] = buf[bufPos++];
|
|
||||||
|
|
||||||
inBufPos = bufPos;
|
|
||||||
nToRead -= fromBuf;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nToRead != 0)
|
|
||||||
{
|
|
||||||
int nRead;
|
|
||||||
|
|
||||||
if (nToRead >= InBufLen)
|
|
||||||
{
|
|
||||||
nRead = input.Read(buffer, offset,
|
|
||||||
nToRead < inputLength ? nToRead : (int)inputLength);
|
|
||||||
nToRead -= nRead;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
nRead = input.Read(buf, DecBufLen,
|
|
||||||
InBufLen < inputLength ? InBufLen : (int)inputLength);
|
|
||||||
|
|
||||||
inBufPos = DecBufLen;
|
|
||||||
inBufEnd = DecBufLen + nRead;
|
|
||||||
|
|
||||||
fromBuf = nToRead < nRead ? nToRead : nRead;
|
|
||||||
|
|
||||||
var bufPos = inBufPos;
|
|
||||||
|
|
||||||
for (int c = fromBuf; c-- != 0;)
|
|
||||||
buffer[offset++] = buf[bufPos++];
|
|
||||||
|
|
||||||
inBufPos = bufPos;
|
|
||||||
nToRead -= fromBuf;
|
|
||||||
}
|
|
||||||
|
|
||||||
inputLength -= nRead;
|
|
||||||
}
|
|
||||||
|
|
||||||
return count - nToRead;
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Stream internals
|
|
||||||
|
|
||||||
public override bool CanRead => true;
|
|
||||||
|
|
||||||
public override bool CanSeek => false;
|
|
||||||
|
|
||||||
public override bool CanWrite => false;
|
|
||||||
|
|
||||||
public override void Flush()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override long Length => throw new NotSupportedException();
|
|
||||||
|
|
||||||
public override long Position
|
|
||||||
{
|
|
||||||
get => throw new NotSupportedException();
|
|
||||||
set => throw new NotSupportedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override long Seek(long offset, SeekOrigin origin)
|
|
||||||
{
|
|
||||||
throw new NotSupportedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void SetLength(long value)
|
|
||||||
{
|
|
||||||
throw new NotSupportedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Write(byte[] buffer, int offset, int count)
|
|
||||||
{
|
|
||||||
throw new NotSupportedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
using System.Diagnostics;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace System
|
namespace AssetStudio
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a half-precision floating point number.
|
/// Represents a half-precision floating point number.
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Runtime.InteropServices;
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace System
|
namespace AssetStudio
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Helper class for Half conversions and some low level operations.
|
/// Helper class for Half conversions and some low level operations.
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ namespace AssetStudio
|
|||||||
public uint byteSize;
|
public uint byteSize;
|
||||||
public int typeID;
|
public int typeID;
|
||||||
public int classID;
|
public int classID;
|
||||||
|
public ushort isDestroyed;
|
||||||
|
public byte stripped;
|
||||||
|
|
||||||
public long m_PathID;
|
public long m_PathID;
|
||||||
public SerializedType serializedType;
|
public SerializedType serializedType;
|
||||||
|
|||||||
@@ -15,12 +15,12 @@ namespace AssetStudio
|
|||||||
public ClassIDType type;
|
public ClassIDType type;
|
||||||
public SerializedType serializedType;
|
public SerializedType serializedType;
|
||||||
public BuildTarget platform;
|
public BuildTarget platform;
|
||||||
public uint m_Version;
|
public SerializedFileFormatVersion m_Version;
|
||||||
|
|
||||||
public int[] version => assetsFile.version;
|
public int[] version => assetsFile.version;
|
||||||
public BuildType buildType => assetsFile.buildType;
|
public BuildType buildType => assetsFile.buildType;
|
||||||
|
|
||||||
public ObjectReader(EndianBinaryReader reader, SerializedFile assetsFile, ObjectInfo objectInfo) : base(reader.BaseStream, reader.endian)
|
public ObjectReader(EndianBinaryReader reader, SerializedFile assetsFile, ObjectInfo objectInfo) : base(reader.BaseStream, reader.Endian)
|
||||||
{
|
{
|
||||||
this.assetsFile = assetsFile;
|
this.assetsFile = assetsFile;
|
||||||
m_PathID = objectInfo.m_PathID;
|
m_PathID = objectInfo.m_PathID;
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
namespace AssetStudio
|
using System;
|
||||||
|
|
||||||
|
namespace AssetStudio
|
||||||
{
|
{
|
||||||
public static class Progress
|
public static class Progress
|
||||||
{
|
{
|
||||||
public static IProgress Default = new DummyProgress();
|
public static IProgress<int> Default = new Progress<int>();
|
||||||
private static int preValue;
|
private static int preValue;
|
||||||
|
|
||||||
public static void Reset()
|
public static void Reset()
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
using System.Reflection;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
// 有关程序集的一般信息由以下
|
|
||||||
// 控制。更改这些特性值可修改
|
|
||||||
// 与程序集关联的信息。
|
|
||||||
[assembly: AssemblyTitle("AssetStudio")]
|
|
||||||
[assembly: AssemblyDescription("")]
|
|
||||||
[assembly: AssemblyConfiguration("")]
|
|
||||||
[assembly: AssemblyCompany("")]
|
|
||||||
[assembly: AssemblyProduct("AssetStudio")]
|
|
||||||
[assembly: AssemblyCopyright("Copyright © Perfare 2018-2020")]
|
|
||||||
[assembly: AssemblyTrademark("")]
|
|
||||||
[assembly: AssemblyCulture("")]
|
|
||||||
|
|
||||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
|
||||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
|
||||||
//请将此类型的 ComVisible 特性设置为 true。
|
|
||||||
[assembly: ComVisible(false)]
|
|
||||||
|
|
||||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
|
||||||
[assembly: Guid("7662f8c2-7bfd-442e-a948-a43b4f7eb06e")]
|
|
||||||
|
|
||||||
// 程序集的版本信息由下列四个值组成:
|
|
||||||
//
|
|
||||||
// 主版本
|
|
||||||
// 次版本
|
|
||||||
// 生成号
|
|
||||||
// 修订号
|
|
||||||
//
|
|
||||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
|
||||||
//通过使用 "*",如下所示:
|
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
|
||||||
[assembly: AssemblyVersion("0.14.38.5")]
|
|
||||||
[assembly: AssemblyFileVersion("0.14.38.5")]
|
|
||||||
@@ -8,11 +8,12 @@ namespace AssetStudio
|
|||||||
private string path;
|
private string path;
|
||||||
private SerializedFile assetsFile;
|
private SerializedFile assetsFile;
|
||||||
private long offset;
|
private long offset;
|
||||||
private int size;
|
private long size;
|
||||||
private BinaryReader reader;
|
private BinaryReader reader;
|
||||||
|
|
||||||
|
public int Size { get => (int)size; }
|
||||||
|
|
||||||
public ResourceReader(string path, SerializedFile assetsFile, long offset, int size)
|
public ResourceReader(string path, SerializedFile assetsFile, long offset, long size)
|
||||||
{
|
{
|
||||||
needSearch = true;
|
needSearch = true;
|
||||||
this.path = path;
|
this.path = path;
|
||||||
@@ -21,28 +22,25 @@ namespace AssetStudio
|
|||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResourceReader(BinaryReader reader, long offset, int size)
|
public ResourceReader(BinaryReader reader, long offset, long size)
|
||||||
{
|
{
|
||||||
this.reader = reader;
|
this.reader = reader;
|
||||||
this.offset = offset;
|
this.offset = offset;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] GetData()
|
private BinaryReader GetReader()
|
||||||
{
|
{
|
||||||
if (needSearch)
|
if (needSearch)
|
||||||
{
|
{
|
||||||
var resourceFileName = Path.GetFileName(path);
|
var resourceFileName = Path.GetFileName(path);
|
||||||
|
|
||||||
if (assetsFile.assetsManager.resourceFileReaders.TryGetValue(resourceFileName, out reader))
|
if (assetsFile.assetsManager.resourceFileReaders.TryGetValue(resourceFileName, out reader))
|
||||||
{
|
{
|
||||||
needSearch = false;
|
needSearch = false;
|
||||||
reader.BaseStream.Position = offset;
|
return reader;
|
||||||
return reader.ReadBytes(size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var assetsFileDirectory = Path.GetDirectoryName(assetsFile.fullName);
|
var assetsFileDirectory = Path.GetDirectoryName(assetsFile.fullName);
|
||||||
var resourceFilePath = assetsFileDirectory + Path.DirectorySeparatorChar + resourceFileName;
|
var resourceFilePath = Path.Combine(assetsFileDirectory, resourceFileName);
|
||||||
if (!File.Exists(resourceFilePath))
|
if (!File.Exists(resourceFilePath))
|
||||||
{
|
{
|
||||||
var findFiles = Directory.GetFiles(assetsFileDirectory, resourceFileName, SearchOption.AllDirectories);
|
var findFiles = Directory.GetFiles(assetsFileDirectory, resourceFileName, SearchOption.AllDirectories);
|
||||||
@@ -53,18 +51,41 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
if (File.Exists(resourceFilePath))
|
if (File.Exists(resourceFilePath))
|
||||||
{
|
{
|
||||||
reader = new BinaryReader(File.OpenRead(resourceFilePath));
|
|
||||||
needSearch = false;
|
needSearch = false;
|
||||||
|
reader = new BinaryReader(File.OpenRead(resourceFilePath));
|
||||||
assetsFile.assetsManager.resourceFileReaders.Add(resourceFileName, reader);
|
assetsFile.assetsManager.resourceFileReaders.Add(resourceFileName, reader);
|
||||||
reader.BaseStream.Position = offset;
|
return reader;
|
||||||
return reader.ReadBytes(size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new FileNotFoundException($"Can't find the resource file {resourceFileName}");
|
throw new FileNotFoundException($"Can't find the resource file {resourceFileName}");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return reader;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
reader.BaseStream.Position = offset;
|
public byte[] GetData()
|
||||||
return reader.ReadBytes(size);
|
{
|
||||||
|
var binaryReader = GetReader();
|
||||||
|
binaryReader.BaseStream.Position = offset;
|
||||||
|
return binaryReader.ReadBytes((int)size);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GetData(byte[] buff)
|
||||||
|
{
|
||||||
|
var binaryReader = GetReader();
|
||||||
|
binaryReader.BaseStream.Position = offset;
|
||||||
|
binaryReader.Read(buff, 0, (int)size);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void WriteData(string path)
|
||||||
|
{
|
||||||
|
var binaryReader = GetReader();
|
||||||
|
binaryReader.BaseStream.Position = offset;
|
||||||
|
using (var writer = File.OpenWrite(path))
|
||||||
|
{
|
||||||
|
binaryReader.BaseStream.CopyTo(writer, size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace AssetStudio
|
|||||||
public class SerializedFile
|
public class SerializedFile
|
||||||
{
|
{
|
||||||
public AssetsManager assetsManager;
|
public AssetsManager assetsManager;
|
||||||
public EndianBinaryReader reader;
|
public FileReader reader;
|
||||||
public string fullName;
|
public string fullName;
|
||||||
public string originalPath;
|
public string originalPath;
|
||||||
public string fileName;
|
public string fileName;
|
||||||
@@ -19,43 +19,45 @@ namespace AssetStudio
|
|||||||
public Dictionary<long, Object> ObjectsDic;
|
public Dictionary<long, Object> ObjectsDic;
|
||||||
|
|
||||||
public SerializedFileHeader header;
|
public SerializedFileHeader header;
|
||||||
private EndianType m_FileEndianess;
|
private byte m_FileEndianess;
|
||||||
public string unityVersion = "2.5.0f5";
|
public string unityVersion = "2.5.0f5";
|
||||||
public BuildTarget m_TargetPlatform = BuildTarget.UnknownPlatform;
|
public BuildTarget m_TargetPlatform = BuildTarget.UnknownPlatform;
|
||||||
private bool m_EnableTypeTree = true;
|
private bool m_EnableTypeTree = true;
|
||||||
public List<SerializedType> m_Types;
|
public List<SerializedType> m_Types;
|
||||||
public List<SerializedType> m_RefTypes;
|
public int bigIDEnabled = 0;
|
||||||
public List<ObjectInfo> m_Objects;
|
public List<ObjectInfo> m_Objects;
|
||||||
private List<LocalSerializedObjectIdentifier> m_ScriptTypes;
|
private List<LocalSerializedObjectIdentifier> m_ScriptTypes;
|
||||||
public List<FileIdentifier> m_Externals;
|
public List<FileIdentifier> m_Externals;
|
||||||
|
public List<SerializedType> m_RefTypes;
|
||||||
|
public string userInformation;
|
||||||
|
|
||||||
public SerializedFile(AssetsManager assetsManager, string fullName, EndianBinaryReader reader)
|
public SerializedFile(FileReader reader, AssetsManager assetsManager)
|
||||||
{
|
{
|
||||||
this.assetsManager = assetsManager;
|
this.assetsManager = assetsManager;
|
||||||
this.reader = reader;
|
this.reader = reader;
|
||||||
this.fullName = fullName;
|
fullName = reader.FullPath;
|
||||||
fileName = Path.GetFileName(fullName);
|
fileName = reader.FileName;
|
||||||
|
|
||||||
//ReadHeader
|
// ReadHeader
|
||||||
header = new SerializedFileHeader();
|
header = new SerializedFileHeader();
|
||||||
header.m_MetadataSize = reader.ReadUInt32();
|
header.m_MetadataSize = reader.ReadUInt32();
|
||||||
header.m_FileSize = reader.ReadUInt32();
|
header.m_FileSize = reader.ReadUInt32();
|
||||||
header.m_Version = reader.ReadUInt32();
|
header.m_Version = (SerializedFileFormatVersion)reader.ReadUInt32();
|
||||||
header.m_DataOffset = reader.ReadUInt32();
|
header.m_DataOffset = reader.ReadUInt32();
|
||||||
|
|
||||||
if (header.m_Version >= 9)
|
if (header.m_Version >= SerializedFileFormatVersion.Unknown_9)
|
||||||
{
|
{
|
||||||
header.m_Endianess = reader.ReadByte();
|
header.m_Endianess = reader.ReadByte();
|
||||||
header.m_Reserved = reader.ReadBytes(3);
|
header.m_Reserved = reader.ReadBytes(3);
|
||||||
m_FileEndianess = (EndianType)header.m_Endianess;
|
m_FileEndianess = header.m_Endianess;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
reader.Position = header.m_FileSize - header.m_MetadataSize;
|
reader.Position = header.m_FileSize - header.m_MetadataSize;
|
||||||
m_FileEndianess = (EndianType)reader.ReadByte();
|
m_FileEndianess = reader.ReadByte();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (header.m_Version >= 22)
|
if (header.m_Version >= SerializedFileFormatVersion.LargeFilesSupport)
|
||||||
{
|
{
|
||||||
header.m_MetadataSize = reader.ReadUInt32();
|
header.m_MetadataSize = reader.ReadUInt32();
|
||||||
header.m_FileSize = reader.ReadInt64();
|
header.m_FileSize = reader.ReadInt64();
|
||||||
@@ -63,17 +65,17 @@ namespace AssetStudio
|
|||||||
reader.ReadInt64(); // unknown
|
reader.ReadInt64(); // unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
//ReadMetadata
|
// ReadMetadata
|
||||||
if (m_FileEndianess == EndianType.LittleEndian)
|
if (m_FileEndianess == 0)
|
||||||
{
|
{
|
||||||
reader.endian = EndianType.LittleEndian;
|
reader.Endian = EndianType.LittleEndian;
|
||||||
}
|
}
|
||||||
if (header.m_Version >= 7)
|
if (header.m_Version >= SerializedFileFormatVersion.Unknown_7)
|
||||||
{
|
{
|
||||||
unityVersion = reader.ReadStringToNull();
|
unityVersion = reader.ReadStringToNull();
|
||||||
SetVersion(unityVersion);
|
SetVersion(unityVersion);
|
||||||
}
|
}
|
||||||
if (header.m_Version >= 8)
|
if (header.m_Version >= SerializedFileFormatVersion.Unknown_8)
|
||||||
{
|
{
|
||||||
m_TargetPlatform = (BuildTarget)reader.ReadInt32();
|
m_TargetPlatform = (BuildTarget)reader.ReadInt32();
|
||||||
if (!Enum.IsDefined(typeof(BuildTarget), m_TargetPlatform))
|
if (!Enum.IsDefined(typeof(BuildTarget), m_TargetPlatform))
|
||||||
@@ -81,26 +83,25 @@ namespace AssetStudio
|
|||||||
m_TargetPlatform = BuildTarget.UnknownPlatform;
|
m_TargetPlatform = BuildTarget.UnknownPlatform;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (header.m_Version >= 13)
|
if (header.m_Version >= SerializedFileFormatVersion.HasTypeTreeHashes)
|
||||||
{
|
{
|
||||||
m_EnableTypeTree = reader.ReadBoolean();
|
m_EnableTypeTree = reader.ReadBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
//ReadTypes
|
// Read Types
|
||||||
int typeCount = reader.ReadInt32();
|
int typeCount = reader.ReadInt32();
|
||||||
m_Types = new List<SerializedType>(typeCount);
|
m_Types = new List<SerializedType>(typeCount);
|
||||||
for (int i = 0; i < typeCount; i++)
|
for (int i = 0; i < typeCount; i++)
|
||||||
{
|
{
|
||||||
m_Types.Add(ReadSerializedType());
|
m_Types.Add(ReadSerializedType(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
var bigIDEnabled = 0;
|
if (header.m_Version >= SerializedFileFormatVersion.Unknown_7 && header.m_Version < SerializedFileFormatVersion.Unknown_14)
|
||||||
if (header.m_Version >= 7 && header.m_Version < 14)
|
|
||||||
{
|
{
|
||||||
bigIDEnabled = reader.ReadInt32();
|
bigIDEnabled = reader.ReadInt32();
|
||||||
}
|
}
|
||||||
|
|
||||||
//ReadObjects
|
// Read Objects
|
||||||
int objectCount = reader.ReadInt32();
|
int objectCount = reader.ReadInt32();
|
||||||
m_Objects = new List<ObjectInfo>(objectCount);
|
m_Objects = new List<ObjectInfo>(objectCount);
|
||||||
Objects = new List<Object>(objectCount);
|
Objects = new List<Object>(objectCount);
|
||||||
@@ -112,7 +113,7 @@ namespace AssetStudio
|
|||||||
{
|
{
|
||||||
objectInfo.m_PathID = reader.ReadInt64();
|
objectInfo.m_PathID = reader.ReadInt64();
|
||||||
}
|
}
|
||||||
else if (header.m_Version < 14)
|
else if (header.m_Version < SerializedFileFormatVersion.Unknown_14)
|
||||||
{
|
{
|
||||||
objectInfo.m_PathID = reader.ReadInt32();
|
objectInfo.m_PathID = reader.ReadInt32();
|
||||||
}
|
}
|
||||||
@@ -122,7 +123,7 @@ namespace AssetStudio
|
|||||||
objectInfo.m_PathID = reader.ReadInt64();
|
objectInfo.m_PathID = reader.ReadInt64();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (header.m_Version >= 22)
|
if (header.m_Version >= SerializedFileFormatVersion.LargeFilesSupport)
|
||||||
objectInfo.byteStart = reader.ReadInt64();
|
objectInfo.byteStart = reader.ReadInt64();
|
||||||
else
|
else
|
||||||
objectInfo.byteStart = reader.ReadUInt32();
|
objectInfo.byteStart = reader.ReadUInt32();
|
||||||
@@ -130,7 +131,7 @@ namespace AssetStudio
|
|||||||
objectInfo.byteStart += header.m_DataOffset;
|
objectInfo.byteStart += header.m_DataOffset;
|
||||||
objectInfo.byteSize = reader.ReadUInt32();
|
objectInfo.byteSize = reader.ReadUInt32();
|
||||||
objectInfo.typeID = reader.ReadInt32();
|
objectInfo.typeID = reader.ReadInt32();
|
||||||
if (header.m_Version < 16)
|
if (header.m_Version < SerializedFileFormatVersion.RefactoredClassId)
|
||||||
{
|
{
|
||||||
objectInfo.classID = reader.ReadUInt16();
|
objectInfo.classID = reader.ReadUInt16();
|
||||||
objectInfo.serializedType = m_Types.Find(x => x.classID == objectInfo.typeID);
|
objectInfo.serializedType = m_Types.Find(x => x.classID == objectInfo.typeID);
|
||||||
@@ -141,24 +142,24 @@ namespace AssetStudio
|
|||||||
objectInfo.serializedType = type;
|
objectInfo.serializedType = type;
|
||||||
objectInfo.classID = type.classID;
|
objectInfo.classID = type.classID;
|
||||||
}
|
}
|
||||||
if (header.m_Version < 11)
|
if (header.m_Version < SerializedFileFormatVersion.HasScriptTypeIndex)
|
||||||
{
|
{
|
||||||
var isDestroyed = reader.ReadUInt16();
|
objectInfo.isDestroyed = reader.ReadUInt16();
|
||||||
}
|
}
|
||||||
if (header.m_Version >= 11 && header.m_Version < 17)
|
if (header.m_Version >= SerializedFileFormatVersion.HasScriptTypeIndex && header.m_Version < SerializedFileFormatVersion.RefactorTypeData)
|
||||||
{
|
{
|
||||||
var m_ScriptTypeIndex = reader.ReadInt16();
|
var m_ScriptTypeIndex = reader.ReadInt16();
|
||||||
if (objectInfo.serializedType != null)
|
if (objectInfo.serializedType != null)
|
||||||
objectInfo.serializedType.m_ScriptTypeIndex = m_ScriptTypeIndex;
|
objectInfo.serializedType.m_ScriptTypeIndex = m_ScriptTypeIndex;
|
||||||
}
|
}
|
||||||
if (header.m_Version == 15 || header.m_Version == 16)
|
if (header.m_Version == SerializedFileFormatVersion.SupportsStrippedObject || header.m_Version == SerializedFileFormatVersion.RefactoredClassId)
|
||||||
{
|
{
|
||||||
var stripped = reader.ReadByte();
|
objectInfo.stripped = reader.ReadByte();
|
||||||
}
|
}
|
||||||
m_Objects.Add(objectInfo);
|
m_Objects.Add(objectInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (header.m_Version >= 11)
|
if (header.m_Version >= SerializedFileFormatVersion.HasScriptTypeIndex)
|
||||||
{
|
{
|
||||||
int scriptCount = reader.ReadInt32();
|
int scriptCount = reader.ReadInt32();
|
||||||
m_ScriptTypes = new List<LocalSerializedObjectIdentifier>(scriptCount);
|
m_ScriptTypes = new List<LocalSerializedObjectIdentifier>(scriptCount);
|
||||||
@@ -166,7 +167,7 @@ namespace AssetStudio
|
|||||||
{
|
{
|
||||||
var m_ScriptType = new LocalSerializedObjectIdentifier();
|
var m_ScriptType = new LocalSerializedObjectIdentifier();
|
||||||
m_ScriptType.localSerializedFileIndex = reader.ReadInt32();
|
m_ScriptType.localSerializedFileIndex = reader.ReadInt32();
|
||||||
if (header.m_Version < 14)
|
if (header.m_Version < SerializedFileFormatVersion.Unknown_14)
|
||||||
{
|
{
|
||||||
m_ScriptType.localIdentifierInFile = reader.ReadInt32();
|
m_ScriptType.localIdentifierInFile = reader.ReadInt32();
|
||||||
}
|
}
|
||||||
@@ -184,11 +185,11 @@ namespace AssetStudio
|
|||||||
for (int i = 0; i < externalsCount; i++)
|
for (int i = 0; i < externalsCount; i++)
|
||||||
{
|
{
|
||||||
var m_External = new FileIdentifier();
|
var m_External = new FileIdentifier();
|
||||||
if (header.m_Version >= 6)
|
if (header.m_Version >= SerializedFileFormatVersion.Unknown_6)
|
||||||
{
|
{
|
||||||
var tempEmpty = reader.ReadStringToNull();
|
var tempEmpty = reader.ReadStringToNull();
|
||||||
}
|
}
|
||||||
if (header.m_Version >= 5)
|
if (header.m_Version >= SerializedFileFormatVersion.Unknown_5)
|
||||||
{
|
{
|
||||||
m_External.guid = new Guid(reader.ReadBytes(16));
|
m_External.guid = new Guid(reader.ReadBytes(16));
|
||||||
m_External.type = reader.ReadInt32();
|
m_External.type = reader.ReadInt32();
|
||||||
@@ -198,19 +199,19 @@ namespace AssetStudio
|
|||||||
m_Externals.Add(m_External);
|
m_Externals.Add(m_External);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (header.m_Version >= 20)
|
if (header.m_Version >= SerializedFileFormatVersion.SupportsRefObject)
|
||||||
{
|
{
|
||||||
int refTypesCount = reader.ReadInt32();
|
int refTypesCount = reader.ReadInt32();
|
||||||
m_RefTypes = new List<SerializedType>(refTypesCount);
|
m_RefTypes = new List<SerializedType>(refTypesCount);
|
||||||
for (int i = 0; i < refTypesCount; i++)
|
for (int i = 0; i < refTypesCount; i++)
|
||||||
{
|
{
|
||||||
m_RefTypes.Add(ReadSerializedType());
|
m_RefTypes.Add(ReadSerializedType(true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (header.m_Version >= 5)
|
if (header.m_Version >= SerializedFileFormatVersion.Unknown_5)
|
||||||
{
|
{
|
||||||
var userInformation = reader.ReadStringToNull();
|
userInformation = reader.ReadStringToNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
//reader.AlignStream(16);
|
//reader.AlignStream(16);
|
||||||
@@ -218,80 +219,98 @@ namespace AssetStudio
|
|||||||
|
|
||||||
public void SetVersion(string stringVersion)
|
public void SetVersion(string stringVersion)
|
||||||
{
|
{
|
||||||
unityVersion = stringVersion;
|
if (stringVersion != strippedVersion)
|
||||||
var buildSplit = Regex.Replace(stringVersion, @"\d", "").Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries);
|
{
|
||||||
buildType = new BuildType(buildSplit[0]);
|
unityVersion = stringVersion;
|
||||||
var versionSplit = Regex.Replace(stringVersion, @"\D", ".").Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries);
|
var buildSplit = Regex.Replace(stringVersion, @"\d", "").Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
version = versionSplit.Select(int.Parse).ToArray();
|
if (buildSplit.Length == 0)
|
||||||
|
throw new NotSupportedException("Specified Unity version is not in a correct format.\n" +
|
||||||
|
"Specify full Unity version, including letters at the end.\n" +
|
||||||
|
"Example: 2017.4.39f1");
|
||||||
|
buildType = new BuildType(buildSplit[0]);
|
||||||
|
var versionSplit = Regex.Replace(stringVersion, @"\D", ".").Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
version = versionSplit.Select(int.Parse).ToArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private SerializedType ReadSerializedType()
|
private SerializedType ReadSerializedType(bool isRefType)
|
||||||
{
|
{
|
||||||
var type = new SerializedType();
|
var type = new SerializedType();
|
||||||
|
|
||||||
type.classID = reader.ReadInt32();
|
type.classID = reader.ReadInt32();
|
||||||
|
|
||||||
if (header.m_Version >= 16)
|
if (header.m_Version >= SerializedFileFormatVersion.RefactoredClassId)
|
||||||
{
|
{
|
||||||
type.m_IsStrippedType = reader.ReadBoolean();
|
type.m_IsStrippedType = reader.ReadBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (header.m_Version >= 17)
|
if (header.m_Version >= SerializedFileFormatVersion.RefactorTypeData)
|
||||||
{
|
{
|
||||||
type.m_ScriptTypeIndex = reader.ReadInt16();
|
type.m_ScriptTypeIndex = reader.ReadInt16();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (header.m_Version >= 13)
|
if (header.m_Version >= SerializedFileFormatVersion.HasTypeTreeHashes)
|
||||||
{
|
{
|
||||||
if ((header.m_Version < 16 && type.classID < 0) || (header.m_Version >= 16 && type.classID == 114))
|
if (isRefType && type.m_ScriptTypeIndex >= 0)
|
||||||
{
|
{
|
||||||
type.m_ScriptID = reader.ReadBytes(16); //Hash128
|
type.m_ScriptID = reader.ReadBytes(16);
|
||||||
}
|
}
|
||||||
type.m_OldTypeHash = reader.ReadBytes(16); //Hash128
|
else if ((header.m_Version < SerializedFileFormatVersion.RefactoredClassId && type.classID < 0) || (header.m_Version >= SerializedFileFormatVersion.RefactoredClassId && type.classID == 114))
|
||||||
|
{
|
||||||
|
type.m_ScriptID = reader.ReadBytes(16);
|
||||||
|
}
|
||||||
|
type.m_OldTypeHash = reader.ReadBytes(16);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_EnableTypeTree)
|
if (m_EnableTypeTree)
|
||||||
{
|
{
|
||||||
var typeTree = new List<TypeTreeNode>();
|
type.m_Type = new TypeTree();
|
||||||
if (header.m_Version >= 12 || header.m_Version == 10)
|
type.m_Type.m_Nodes = new List<TypeTreeNode>();
|
||||||
|
if (header.m_Version >= SerializedFileFormatVersion.Unknown_12 || header.m_Version == SerializedFileFormatVersion.Unknown_10)
|
||||||
{
|
{
|
||||||
TypeTreeBlobRead(typeTree);
|
TypeTreeBlobRead(type.m_Type);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ReadTypeTree(typeTree);
|
ReadTypeTree(type.m_Type);
|
||||||
}
|
}
|
||||||
|
if (header.m_Version >= SerializedFileFormatVersion.StoresTypeDependencies)
|
||||||
if (header.m_Version >= 21)
|
|
||||||
{
|
{
|
||||||
type.m_TypeDependencies = reader.ReadInt32Array();
|
if (isRefType)
|
||||||
|
{
|
||||||
|
type.m_KlassName = reader.ReadStringToNull();
|
||||||
|
type.m_NameSpace = reader.ReadStringToNull();
|
||||||
|
type.m_AsmName = reader.ReadStringToNull();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
type.m_TypeDependencies = reader.ReadInt32Array();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type.m_Nodes = typeTree;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReadTypeTree(List<TypeTreeNode> typeTree, int level = 0)
|
private void ReadTypeTree(TypeTree m_Type, int level = 0)
|
||||||
{
|
{
|
||||||
var typeTreeNode = new TypeTreeNode();
|
var typeTreeNode = new TypeTreeNode();
|
||||||
typeTree.Add(typeTreeNode);
|
m_Type.m_Nodes.Add(typeTreeNode);
|
||||||
typeTreeNode.m_Level = level;
|
typeTreeNode.m_Level = level;
|
||||||
typeTreeNode.m_Type = reader.ReadStringToNull();
|
typeTreeNode.m_Type = reader.ReadStringToNull();
|
||||||
typeTreeNode.m_Name = reader.ReadStringToNull();
|
typeTreeNode.m_Name = reader.ReadStringToNull();
|
||||||
typeTreeNode.m_ByteSize = reader.ReadInt32();
|
typeTreeNode.m_ByteSize = reader.ReadInt32();
|
||||||
if (header.m_Version == 2)
|
if (header.m_Version == SerializedFileFormatVersion.Unknown_2)
|
||||||
{
|
{
|
||||||
var variableCount = reader.ReadInt32();
|
var variableCount = reader.ReadInt32();
|
||||||
}
|
}
|
||||||
if (header.m_Version != 3)
|
if (header.m_Version != SerializedFileFormatVersion.Unknown_3)
|
||||||
{
|
{
|
||||||
typeTreeNode.m_Index = reader.ReadInt32();
|
typeTreeNode.m_Index = reader.ReadInt32();
|
||||||
}
|
}
|
||||||
typeTreeNode.m_IsArray = reader.ReadInt32();
|
typeTreeNode.m_TypeFlags = reader.ReadInt32();
|
||||||
typeTreeNode.m_Version = reader.ReadInt32();
|
typeTreeNode.m_Version = reader.ReadInt32();
|
||||||
if (header.m_Version != 3)
|
if (header.m_Version != SerializedFileFormatVersion.Unknown_3)
|
||||||
{
|
{
|
||||||
typeTreeNode.m_MetaFlag = reader.ReadInt32();
|
typeTreeNode.m_MetaFlag = reader.ReadInt32();
|
||||||
}
|
}
|
||||||
@@ -299,40 +318,40 @@ namespace AssetStudio
|
|||||||
int childrenCount = reader.ReadInt32();
|
int childrenCount = reader.ReadInt32();
|
||||||
for (int i = 0; i < childrenCount; i++)
|
for (int i = 0; i < childrenCount; i++)
|
||||||
{
|
{
|
||||||
ReadTypeTree(typeTree, level + 1);
|
ReadTypeTree(m_Type, level + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TypeTreeBlobRead(List<TypeTreeNode> typeTree)
|
private void TypeTreeBlobRead(TypeTree m_Type)
|
||||||
{
|
{
|
||||||
int numberOfNodes = reader.ReadInt32();
|
int numberOfNodes = reader.ReadInt32();
|
||||||
int stringBufferSize = reader.ReadInt32();
|
int stringBufferSize = reader.ReadInt32();
|
||||||
for (int i = 0; i < numberOfNodes; i++)
|
for (int i = 0; i < numberOfNodes; i++)
|
||||||
{
|
{
|
||||||
var typeTreeNode = new TypeTreeNode();
|
var typeTreeNode = new TypeTreeNode();
|
||||||
typeTree.Add(typeTreeNode);
|
m_Type.m_Nodes.Add(typeTreeNode);
|
||||||
typeTreeNode.m_Version = reader.ReadUInt16();
|
typeTreeNode.m_Version = reader.ReadUInt16();
|
||||||
typeTreeNode.m_Level = reader.ReadByte();
|
typeTreeNode.m_Level = reader.ReadByte();
|
||||||
typeTreeNode.m_IsArray = reader.ReadBoolean() ? 1 : 0;
|
typeTreeNode.m_TypeFlags = reader.ReadByte();
|
||||||
typeTreeNode.m_TypeStrOffset = reader.ReadUInt32();
|
typeTreeNode.m_TypeStrOffset = reader.ReadUInt32();
|
||||||
typeTreeNode.m_NameStrOffset = reader.ReadUInt32();
|
typeTreeNode.m_NameStrOffset = reader.ReadUInt32();
|
||||||
typeTreeNode.m_ByteSize = reader.ReadInt32();
|
typeTreeNode.m_ByteSize = reader.ReadInt32();
|
||||||
typeTreeNode.m_Index = reader.ReadInt32();
|
typeTreeNode.m_Index = reader.ReadInt32();
|
||||||
typeTreeNode.m_MetaFlag = reader.ReadInt32();
|
typeTreeNode.m_MetaFlag = reader.ReadInt32();
|
||||||
if (header.m_Version >= 19)
|
if (header.m_Version >= SerializedFileFormatVersion.TypeTreeNodeWithTypeFlags)
|
||||||
{
|
{
|
||||||
typeTreeNode.m_RefTypeHash = reader.ReadUInt64();
|
typeTreeNode.m_RefTypeHash = reader.ReadUInt64();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var m_StringBuffer = reader.ReadBytes(stringBufferSize);
|
m_Type.m_StringBuffer = reader.ReadBytes(stringBufferSize);
|
||||||
|
|
||||||
using (var stringBufferReader = new BinaryReader(new MemoryStream(m_StringBuffer)))
|
using (var stringBufferReader = new BinaryReader(new MemoryStream(m_Type.m_StringBuffer)))
|
||||||
{
|
{
|
||||||
for (int i = 0; i < numberOfNodes; i++)
|
for (int i = 0; i < numberOfNodes; i++)
|
||||||
{
|
{
|
||||||
var typeTreeNode = typeTree[i];
|
var m_Node = m_Type.m_Nodes[i];
|
||||||
typeTreeNode.m_Type = ReadString(stringBufferReader, typeTreeNode.m_TypeStrOffset);
|
m_Node.m_Type = ReadString(stringBufferReader, m_Node.m_TypeStrOffset);
|
||||||
typeTreeNode.m_Name = ReadString(stringBufferReader, typeTreeNode.m_NameStrOffset);
|
m_Node.m_Name = ReadString(stringBufferReader, m_Node.m_NameStrOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,41 +378,8 @@ namespace AssetStudio
|
|||||||
ObjectsDic.Add(obj.m_PathID, obj);
|
ObjectsDic.Add(obj.m_PathID, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsSerializedFile(EndianBinaryReader reader)
|
public bool IsVersionStripped => unityVersion == strippedVersion;
|
||||||
{
|
|
||||||
var fileSize = reader.BaseStream.Length;
|
private const string strippedVersion = "0.0.0";
|
||||||
if (fileSize < 20)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
var m_MetadataSize = reader.ReadUInt32();
|
|
||||||
long m_FileSize = reader.ReadUInt32();
|
|
||||||
var m_Version = reader.ReadUInt32();
|
|
||||||
long m_DataOffset = reader.ReadUInt32();
|
|
||||||
var m_Endianess = reader.ReadByte();
|
|
||||||
var m_Reserved = reader.ReadBytes(3);
|
|
||||||
if (m_Version >= 22)
|
|
||||||
{
|
|
||||||
if (fileSize < 48)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
m_MetadataSize = reader.ReadUInt32();
|
|
||||||
m_FileSize = reader.ReadInt64();
|
|
||||||
m_DataOffset = reader.ReadInt64();
|
|
||||||
}
|
|
||||||
if (m_FileSize != fileSize)
|
|
||||||
{
|
|
||||||
reader.Position = 0;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (m_DataOffset > fileSize)
|
|
||||||
{
|
|
||||||
reader.Position = 0;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
reader.Position = 0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
87
AssetStudio/SerializedFileFormatVersion.cs
Normal file
87
AssetStudio/SerializedFileFormatVersion.cs
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AssetStudio
|
||||||
|
{
|
||||||
|
public enum SerializedFileFormatVersion
|
||||||
|
{
|
||||||
|
Unsupported = 1,
|
||||||
|
Unknown_2 = 2,
|
||||||
|
Unknown_3 = 3,
|
||||||
|
/// <summary>
|
||||||
|
/// 1.2.0 to 2.0.0
|
||||||
|
/// </summary>
|
||||||
|
Unknown_5 = 5,
|
||||||
|
/// <summary>
|
||||||
|
/// 2.1.0 to 2.6.1
|
||||||
|
/// </summary>
|
||||||
|
Unknown_6 = 6,
|
||||||
|
/// <summary>
|
||||||
|
/// 3.0.0b
|
||||||
|
/// </summary>
|
||||||
|
Unknown_7 = 7,
|
||||||
|
/// <summary>
|
||||||
|
/// 3.0.0 to 3.4.2
|
||||||
|
/// </summary>
|
||||||
|
Unknown_8 = 8,
|
||||||
|
/// <summary>
|
||||||
|
/// 3.5.0 to 4.7.2
|
||||||
|
/// </summary>
|
||||||
|
Unknown_9 = 9,
|
||||||
|
/// <summary>
|
||||||
|
/// 5.0.0aunk1
|
||||||
|
/// </summary>
|
||||||
|
Unknown_10 = 10,
|
||||||
|
/// <summary>
|
||||||
|
/// 5.0.0aunk2
|
||||||
|
/// </summary>
|
||||||
|
HasScriptTypeIndex = 11,
|
||||||
|
/// <summary>
|
||||||
|
/// 5.0.0aunk3
|
||||||
|
/// </summary>
|
||||||
|
Unknown_12 = 12,
|
||||||
|
/// <summary>
|
||||||
|
/// 5.0.0aunk4
|
||||||
|
/// </summary>
|
||||||
|
HasTypeTreeHashes = 13,
|
||||||
|
/// <summary>
|
||||||
|
/// 5.0.0unk
|
||||||
|
/// </summary>
|
||||||
|
Unknown_14 = 14,
|
||||||
|
/// <summary>
|
||||||
|
/// 5.0.1 to 5.4.0
|
||||||
|
/// </summary>
|
||||||
|
SupportsStrippedObject = 15,
|
||||||
|
/// <summary>
|
||||||
|
/// 5.5.0a
|
||||||
|
/// </summary>
|
||||||
|
RefactoredClassId = 16,
|
||||||
|
/// <summary>
|
||||||
|
/// 5.5.0unk to 2018.4
|
||||||
|
/// </summary>
|
||||||
|
RefactorTypeData = 17,
|
||||||
|
/// <summary>
|
||||||
|
/// 2019.1a
|
||||||
|
/// </summary>
|
||||||
|
RefactorShareableTypeTreeData = 18,
|
||||||
|
/// <summary>
|
||||||
|
/// 2019.1unk
|
||||||
|
/// </summary>
|
||||||
|
TypeTreeNodeWithTypeFlags = 19,
|
||||||
|
/// <summary>
|
||||||
|
/// 2019.2
|
||||||
|
/// </summary>
|
||||||
|
SupportsRefObject = 20,
|
||||||
|
/// <summary>
|
||||||
|
/// 2019.3 to 2019.4
|
||||||
|
/// </summary>
|
||||||
|
StoresTypeDependencies = 21,
|
||||||
|
/// <summary>
|
||||||
|
/// 2020.1 to x
|
||||||
|
/// </summary>
|
||||||
|
LargeFilesSupport = 22
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,7 +9,7 @@ namespace AssetStudio
|
|||||||
{
|
{
|
||||||
public uint m_MetadataSize;
|
public uint m_MetadataSize;
|
||||||
public long m_FileSize;
|
public long m_FileSize;
|
||||||
public uint m_Version;
|
public SerializedFileFormatVersion m_Version;
|
||||||
public long m_DataOffset;
|
public long m_DataOffset;
|
||||||
public byte m_Endianess;
|
public byte m_Endianess;
|
||||||
public byte[] m_Reserved;
|
public byte[] m_Reserved;
|
||||||
|
|||||||
@@ -10,9 +10,12 @@ namespace AssetStudio
|
|||||||
public int classID;
|
public int classID;
|
||||||
public bool m_IsStrippedType;
|
public bool m_IsStrippedType;
|
||||||
public short m_ScriptTypeIndex = -1;
|
public short m_ScriptTypeIndex = -1;
|
||||||
public List<TypeTreeNode> m_Nodes;
|
public TypeTree m_Type;
|
||||||
public byte[] m_ScriptID; //Hash128
|
public byte[] m_ScriptID; //Hash128
|
||||||
public byte[] m_OldTypeHash; //Hash128
|
public byte[] m_OldTypeHash; //Hash128
|
||||||
public int[] m_TypeDependencies;
|
public int[] m_TypeDependencies;
|
||||||
|
public string m_KlassName;
|
||||||
|
public string m_NameSpace;
|
||||||
|
public string m_AsmName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,15 +34,16 @@ namespace AssetStudio
|
|||||||
return newOutStream;
|
return newOutStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void StreamDecompress(Stream inStream, Stream outStream, long inSize, long outSize)
|
public static void StreamDecompress(Stream compressedStream, Stream decompressedStream, long compressedSize, long decompressedSize)
|
||||||
{
|
{
|
||||||
|
var basePosition = compressedStream.Position;
|
||||||
var decoder = new Decoder();
|
var decoder = new Decoder();
|
||||||
var properties = new byte[5];
|
var properties = new byte[5];
|
||||||
if (inStream.Read(properties, 0, 5) != 5)
|
if (compressedStream.Read(properties, 0, 5) != 5)
|
||||||
throw new Exception("input .lzma is too short");
|
throw new Exception("input .lzma is too short");
|
||||||
decoder.SetDecoderProperties(properties);
|
decoder.SetDecoderProperties(properties);
|
||||||
inSize -= 5L;
|
decoder.Code(compressedStream, decompressedStream, compressedSize - 5, decompressedSize, null);
|
||||||
decoder.Code(inStream, outStream, inSize, outSize, null);
|
compressedStream.Position = basePosition + compressedSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace AssetStudio
|
|||||||
{
|
{
|
||||||
public class StreamFile
|
public class StreamFile
|
||||||
{
|
{
|
||||||
|
public string path;
|
||||||
public string fileName;
|
public string fileName;
|
||||||
public Stream stream;
|
public Stream stream;
|
||||||
}
|
}
|
||||||
|
|||||||
14
AssetStudio/TypeTree.cs
Normal file
14
AssetStudio/TypeTree.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AssetStudio
|
||||||
|
{
|
||||||
|
public class TypeTree
|
||||||
|
{
|
||||||
|
public List<TypeTreeNode> m_Nodes;
|
||||||
|
public byte[] m_StringBuffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,39 +1,50 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.Specialized;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace AssetStudio
|
namespace AssetStudio
|
||||||
{
|
{
|
||||||
public static class TypeTreeHelper
|
public static class TypeTreeHelper
|
||||||
{
|
{
|
||||||
public static void ReadTypeString(StringBuilder sb, List<TypeTreeNode> members, BinaryReader reader)
|
public static string ReadTypeString(TypeTree m_Type, ObjectReader reader)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < members.Count; i++)
|
reader.Reset();
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
var m_Nodes = m_Type.m_Nodes;
|
||||||
|
for (int i = 0; i < m_Nodes.Count; i++)
|
||||||
{
|
{
|
||||||
ReadStringValue(sb, members, reader, ref i);
|
ReadStringValue(sb, m_Nodes, reader, ref i);
|
||||||
}
|
}
|
||||||
|
var readed = reader.Position - reader.byteStart;
|
||||||
|
if (readed != reader.byteSize)
|
||||||
|
{
|
||||||
|
Logger.Info($"Error while read type, read {readed} bytes but expected {reader.byteSize} bytes");
|
||||||
|
}
|
||||||
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ReadStringValue(StringBuilder sb, List<TypeTreeNode> members, BinaryReader reader, ref int i)
|
private static void ReadStringValue(StringBuilder sb, List<TypeTreeNode> m_Nodes, BinaryReader reader, ref int i)
|
||||||
{
|
{
|
||||||
var member = members[i];
|
var m_Node = m_Nodes[i];
|
||||||
var level = member.m_Level;
|
var level = m_Node.m_Level;
|
||||||
var varTypeStr = member.m_Type;
|
var varTypeStr = m_Node.m_Type;
|
||||||
var varNameStr = member.m_Name;
|
var varNameStr = m_Node.m_Name;
|
||||||
object value = null;
|
object value = null;
|
||||||
var append = true;
|
var append = true;
|
||||||
var align = (member.m_MetaFlag & 0x4000) != 0;
|
var align = (m_Node.m_MetaFlag & 0x4000) != 0;
|
||||||
switch (varTypeStr)
|
switch (varTypeStr)
|
||||||
{
|
{
|
||||||
case "SInt8":
|
case "SInt8":
|
||||||
value = reader.ReadSByte();
|
value = reader.ReadSByte();
|
||||||
break;
|
break;
|
||||||
case "UInt8":
|
case "UInt8":
|
||||||
case "char":
|
|
||||||
value = reader.ReadByte();
|
value = reader.ReadByte();
|
||||||
break;
|
break;
|
||||||
|
case "char":
|
||||||
|
value = BitConverter.ToChar(reader.ReadBytes(2), 0);
|
||||||
|
break;
|
||||||
case "short":
|
case "short":
|
||||||
case "SInt16":
|
case "SInt16":
|
||||||
value = reader.ReadInt16();
|
value = reader.ReadInt16();
|
||||||
@@ -73,22 +84,23 @@ namespace AssetStudio
|
|||||||
append = false;
|
append = false;
|
||||||
var str = reader.ReadAlignedString();
|
var str = reader.ReadAlignedString();
|
||||||
sb.AppendFormat("{0}{1} {2} = \"{3}\"\r\n", (new string('\t', level)), varTypeStr, varNameStr, str);
|
sb.AppendFormat("{0}{1} {2} = \"{3}\"\r\n", (new string('\t', level)), varTypeStr, varNameStr, str);
|
||||||
i += 3;
|
var toSkip = GetNodes(m_Nodes, i);
|
||||||
|
i += toSkip.Count - 1;
|
||||||
break;
|
break;
|
||||||
case "map":
|
case "map":
|
||||||
{
|
{
|
||||||
if ((members[i + 1].m_MetaFlag & 0x4000) != 0)
|
if ((m_Nodes[i + 1].m_MetaFlag & 0x4000) != 0)
|
||||||
align = true;
|
align = true;
|
||||||
append = false;
|
append = false;
|
||||||
sb.AppendFormat("{0}{1} {2}\r\n", (new string('\t', level)), varTypeStr, varNameStr);
|
sb.AppendFormat("{0}{1} {2}\r\n", (new string('\t', level)), varTypeStr, varNameStr);
|
||||||
sb.AppendFormat("{0}{1} {2}\r\n", (new string('\t', level + 1)), "Array", "Array");
|
sb.AppendFormat("{0}{1} {2}\r\n", (new string('\t', level + 1)), "Array", "Array");
|
||||||
var size = reader.ReadInt32();
|
var size = reader.ReadInt32();
|
||||||
sb.AppendFormat("{0}{1} {2} = {3}\r\n", (new string('\t', level + 1)), "int", "size", size);
|
sb.AppendFormat("{0}{1} {2} = {3}\r\n", (new string('\t', level + 1)), "int", "size", size);
|
||||||
var map = GetMembers(members, i);
|
var map = GetNodes(m_Nodes, i);
|
||||||
i += map.Count - 1;
|
i += map.Count - 1;
|
||||||
var first = GetMembers(map, 4);
|
var first = GetNodes(map, 4);
|
||||||
var next = 4 + first.Count;
|
var next = 4 + first.Count;
|
||||||
var second = GetMembers(map, next);
|
var second = GetNodes(map, next);
|
||||||
for (int j = 0; j < size; j++)
|
for (int j = 0; j < size; j++)
|
||||||
{
|
{
|
||||||
sb.AppendFormat("{0}[{1}]\r\n", (new string('\t', level + 2)), j);
|
sb.AppendFormat("{0}[{1}]\r\n", (new string('\t', level + 2)), j);
|
||||||
@@ -112,16 +124,16 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
if (i < members.Count - 1 && members[i + 1].m_Type == "Array") //Array
|
if (i < m_Nodes.Count - 1 && m_Nodes[i + 1].m_Type == "Array") //Array
|
||||||
{
|
{
|
||||||
if ((members[i + 1].m_MetaFlag & 0x4000) != 0)
|
if ((m_Nodes[i + 1].m_MetaFlag & 0x4000) != 0)
|
||||||
align = true;
|
align = true;
|
||||||
append = false;
|
append = false;
|
||||||
sb.AppendFormat("{0}{1} {2}\r\n", (new string('\t', level)), varTypeStr, varNameStr);
|
sb.AppendFormat("{0}{1} {2}\r\n", (new string('\t', level)), varTypeStr, varNameStr);
|
||||||
sb.AppendFormat("{0}{1} {2}\r\n", (new string('\t', level + 1)), "Array", "Array");
|
sb.AppendFormat("{0}{1} {2}\r\n", (new string('\t', level + 1)), "Array", "Array");
|
||||||
var size = reader.ReadInt32();
|
var size = reader.ReadInt32();
|
||||||
sb.AppendFormat("{0}{1} {2} = {3}\r\n", (new string('\t', level + 1)), "int", "size", size);
|
sb.AppendFormat("{0}{1} {2} = {3}\r\n", (new string('\t', level + 1)), "int", "size", size);
|
||||||
var vector = GetMembers(members, i);
|
var vector = GetNodes(m_Nodes, i);
|
||||||
i += vector.Count - 1;
|
i += vector.Count - 1;
|
||||||
for (int j = 0; j < size; j++)
|
for (int j = 0; j < size; j++)
|
||||||
{
|
{
|
||||||
@@ -135,7 +147,7 @@ namespace AssetStudio
|
|||||||
{
|
{
|
||||||
append = false;
|
append = false;
|
||||||
sb.AppendFormat("{0}{1} {2}\r\n", (new string('\t', level)), varTypeStr, varNameStr);
|
sb.AppendFormat("{0}{1} {2}\r\n", (new string('\t', level)), varTypeStr, varNameStr);
|
||||||
var @class = GetMembers(members, i);
|
var @class = GetNodes(m_Nodes, i);
|
||||||
i += @class.Count - 1;
|
i += @class.Count - 1;
|
||||||
for (int j = 1; j < @class.Count; j++)
|
for (int j = 1; j < @class.Count; j++)
|
||||||
{
|
{
|
||||||
@@ -151,33 +163,42 @@ namespace AssetStudio
|
|||||||
reader.AlignStream();
|
reader.AlignStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UType ReadUType(List<TypeTreeNode> members, BinaryReader reader)
|
public static OrderedDictionary ReadType(TypeTree m_Types, ObjectReader reader)
|
||||||
{
|
{
|
||||||
var obj = new UType();
|
reader.Reset();
|
||||||
for (int i = 1; i < members.Count; i++)
|
var obj = new OrderedDictionary();
|
||||||
|
var m_Nodes = m_Types.m_Nodes;
|
||||||
|
for (int i = 1; i < m_Nodes.Count; i++)
|
||||||
{
|
{
|
||||||
var member = members[i];
|
var m_Node = m_Nodes[i];
|
||||||
var varNameStr = member.m_Name;
|
var varNameStr = m_Node.m_Name;
|
||||||
obj[varNameStr] = ReadValue(members, reader, ref i);
|
obj[varNameStr] = ReadValue(m_Nodes, reader, ref i);
|
||||||
|
}
|
||||||
|
var readed = reader.Position - reader.byteStart;
|
||||||
|
if (readed != reader.byteSize)
|
||||||
|
{
|
||||||
|
Logger.Info($"Error while read type, read {readed} bytes but expected {reader.byteSize} bytes");
|
||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static object ReadValue(List<TypeTreeNode> members, BinaryReader reader, ref int i)
|
private static object ReadValue(List<TypeTreeNode> m_Nodes, BinaryReader reader, ref int i)
|
||||||
{
|
{
|
||||||
var member = members[i];
|
var m_Node = m_Nodes[i];
|
||||||
var varTypeStr = member.m_Type;
|
var varTypeStr = m_Node.m_Type;
|
||||||
object value;
|
object value;
|
||||||
var align = (member.m_MetaFlag & 0x4000) != 0;
|
var align = (m_Node.m_MetaFlag & 0x4000) != 0;
|
||||||
switch (varTypeStr)
|
switch (varTypeStr)
|
||||||
{
|
{
|
||||||
case "SInt8":
|
case "SInt8":
|
||||||
value = reader.ReadSByte();
|
value = reader.ReadSByte();
|
||||||
break;
|
break;
|
||||||
case "UInt8":
|
case "UInt8":
|
||||||
case "char":
|
|
||||||
value = reader.ReadByte();
|
value = reader.ReadByte();
|
||||||
break;
|
break;
|
||||||
|
case "char":
|
||||||
|
value = BitConverter.ToChar(reader.ReadBytes(2), 0);
|
||||||
|
break;
|
||||||
case "short":
|
case "short":
|
||||||
case "SInt16":
|
case "SInt16":
|
||||||
value = reader.ReadInt16();
|
value = reader.ReadInt16();
|
||||||
@@ -215,17 +236,18 @@ namespace AssetStudio
|
|||||||
break;
|
break;
|
||||||
case "string":
|
case "string":
|
||||||
value = reader.ReadAlignedString();
|
value = reader.ReadAlignedString();
|
||||||
i += 3;
|
var toSkip = GetNodes(m_Nodes, i);
|
||||||
|
i += toSkip.Count - 1;
|
||||||
break;
|
break;
|
||||||
case "map":
|
case "map":
|
||||||
{
|
{
|
||||||
if ((members[i + 1].m_MetaFlag & 0x4000) != 0)
|
if ((m_Nodes[i + 1].m_MetaFlag & 0x4000) != 0)
|
||||||
align = true;
|
align = true;
|
||||||
var map = GetMembers(members, i);
|
var map = GetNodes(m_Nodes, i);
|
||||||
i += map.Count - 1;
|
i += map.Count - 1;
|
||||||
var first = GetMembers(map, 4);
|
var first = GetNodes(map, 4);
|
||||||
var next = 4 + first.Count;
|
var next = 4 + first.Count;
|
||||||
var second = GetMembers(map, next);
|
var second = GetNodes(map, next);
|
||||||
var size = reader.ReadInt32();
|
var size = reader.ReadInt32();
|
||||||
var dic = new List<KeyValuePair<object, object>>(size);
|
var dic = new List<KeyValuePair<object, object>>(size);
|
||||||
for (int j = 0; j < size; j++)
|
for (int j = 0; j < size; j++)
|
||||||
@@ -246,11 +268,11 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
if (i < members.Count - 1 && members[i + 1].m_Type == "Array") //Array
|
if (i < m_Nodes.Count - 1 && m_Nodes[i + 1].m_Type == "Array") //Array
|
||||||
{
|
{
|
||||||
if ((members[i + 1].m_MetaFlag & 0x4000) != 0)
|
if ((m_Nodes[i + 1].m_MetaFlag & 0x4000) != 0)
|
||||||
align = true;
|
align = true;
|
||||||
var vector = GetMembers(members, i);
|
var vector = GetNodes(m_Nodes, i);
|
||||||
i += vector.Count - 1;
|
i += vector.Count - 1;
|
||||||
var size = reader.ReadInt32();
|
var size = reader.ReadInt32();
|
||||||
var list = new List<object>(size);
|
var list = new List<object>(size);
|
||||||
@@ -264,9 +286,9 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
else //Class
|
else //Class
|
||||||
{
|
{
|
||||||
var @class = GetMembers(members, i);
|
var @class = GetNodes(m_Nodes, i);
|
||||||
i += @class.Count - 1;
|
i += @class.Count - 1;
|
||||||
var obj = new UType();
|
var obj = new OrderedDictionary();
|
||||||
for (int j = 1; j < @class.Count; j++)
|
for (int j = 1; j < @class.Count; j++)
|
||||||
{
|
{
|
||||||
var classmember = @class[j];
|
var classmember = @class[j];
|
||||||
@@ -283,22 +305,22 @@ namespace AssetStudio
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<TypeTreeNode> GetMembers(List<TypeTreeNode> members, int index)
|
private static List<TypeTreeNode> GetNodes(List<TypeTreeNode> m_Nodes, int index)
|
||||||
{
|
{
|
||||||
var member2 = new List<TypeTreeNode>();
|
var nodes = new List<TypeTreeNode>();
|
||||||
member2.Add(members[index]);
|
nodes.Add(m_Nodes[index]);
|
||||||
var level = members[index].m_Level;
|
var level = m_Nodes[index].m_Level;
|
||||||
for (int i = index + 1; i < members.Count; i++)
|
for (int i = index + 1; i < m_Nodes.Count; i++)
|
||||||
{
|
{
|
||||||
var member = members[i];
|
var member = m_Nodes[i];
|
||||||
var level2 = member.m_Level;
|
var level2 = member.m_Level;
|
||||||
if (level2 <= level)
|
if (level2 <= level)
|
||||||
{
|
{
|
||||||
return member2;
|
return nodes;
|
||||||
}
|
}
|
||||||
member2.Add(member);
|
nodes.Add(member);
|
||||||
}
|
}
|
||||||
return member2;
|
return nodes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,12 +11,22 @@ namespace AssetStudio
|
|||||||
public string m_Name;
|
public string m_Name;
|
||||||
public int m_ByteSize;
|
public int m_ByteSize;
|
||||||
public int m_Index;
|
public int m_Index;
|
||||||
public int m_IsArray; //m_TypeFlags
|
public int m_TypeFlags; //m_IsArray
|
||||||
public int m_Version;
|
public int m_Version;
|
||||||
public int m_MetaFlag;
|
public int m_MetaFlag;
|
||||||
public int m_Level;
|
public int m_Level;
|
||||||
public uint m_TypeStrOffset;
|
public uint m_TypeStrOffset;
|
||||||
public uint m_NameStrOffset;
|
public uint m_NameStrOffset;
|
||||||
public ulong m_RefTypeHash;
|
public ulong m_RefTypeHash;
|
||||||
|
|
||||||
|
public TypeTreeNode() { }
|
||||||
|
|
||||||
|
public TypeTreeNode(string type, string name, int level, bool align)
|
||||||
|
{
|
||||||
|
m_Type = type;
|
||||||
|
m_Name = name;
|
||||||
|
m_Level = level;
|
||||||
|
m_MetaFlag = align ? 0x4000 : 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,108 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace AssetStudio
|
|
||||||
{
|
|
||||||
public class UType : IDictionary<string, object>
|
|
||||||
{
|
|
||||||
private List<string> keys;
|
|
||||||
private IDictionary<string, object> values;
|
|
||||||
|
|
||||||
public UType()
|
|
||||||
{
|
|
||||||
keys = new List<string>();
|
|
||||||
values = new Dictionary<string, object>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public object this[string key]
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (!values.ContainsKey(key))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return values[key];
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (!values.ContainsKey(key))
|
|
||||||
{
|
|
||||||
keys.Add(key);
|
|
||||||
}
|
|
||||||
values[key] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICollection<string> Keys => keys;
|
|
||||||
|
|
||||||
public ICollection<object> Values => values.Values;
|
|
||||||
|
|
||||||
public int Count => keys.Count;
|
|
||||||
|
|
||||||
public bool IsReadOnly => false;
|
|
||||||
|
|
||||||
public void Add(string key, object value)
|
|
||||||
{
|
|
||||||
keys.Add(key);
|
|
||||||
values.Add(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Add(KeyValuePair<string, object> item)
|
|
||||||
{
|
|
||||||
keys.Add(item.Key);
|
|
||||||
values.Add(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Clear()
|
|
||||||
{
|
|
||||||
keys.Clear();
|
|
||||||
values.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Contains(KeyValuePair<string, object> item)
|
|
||||||
{
|
|
||||||
return values.Contains(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool ContainsKey(string key)
|
|
||||||
{
|
|
||||||
return values.ContainsKey(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CopyTo(KeyValuePair<string, object>[] array, int arrayIndex)
|
|
||||||
{
|
|
||||||
values.CopyTo(array, arrayIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
|
|
||||||
{
|
|
||||||
return values.GetEnumerator();
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Remove(string key)
|
|
||||||
{
|
|
||||||
keys.Remove(key);
|
|
||||||
return values.Remove(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Remove(KeyValuePair<string, object> item)
|
|
||||||
{
|
|
||||||
keys.Remove(item.Key);
|
|
||||||
return values.Remove(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool TryGetValue(string key, out object value)
|
|
||||||
{
|
|
||||||
return values.TryGetValue(key, out value);
|
|
||||||
}
|
|
||||||
|
|
||||||
IEnumerator IEnumerable.GetEnumerator()
|
|
||||||
{
|
|
||||||
return values.GetEnumerator();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +1,11 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Compression;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Org.Brotli.Dec;
|
|
||||||
|
|
||||||
namespace AssetStudio
|
namespace AssetStudio
|
||||||
{
|
{
|
||||||
public class WebFile
|
public class WebFile
|
||||||
{
|
{
|
||||||
public static byte[] gzipMagic = { 0x1f, 0x8b };
|
|
||||||
public static byte[] brotliMagic = { 0x62, 0x72, 0x6F, 0x74, 0x6C, 0x69 };
|
|
||||||
public StreamFile[] fileList;
|
public StreamFile[] fileList;
|
||||||
|
|
||||||
private class WebData
|
private class WebData
|
||||||
@@ -23,50 +17,8 @@ namespace AssetStudio
|
|||||||
|
|
||||||
public WebFile(EndianBinaryReader reader)
|
public WebFile(EndianBinaryReader reader)
|
||||||
{
|
{
|
||||||
var magic = reader.ReadBytes(2);
|
reader.Endian = EndianType.LittleEndian;
|
||||||
reader.Position = 0;
|
|
||||||
if (gzipMagic.SequenceEqual(magic))
|
|
||||||
{
|
|
||||||
var stream = new MemoryStream();
|
|
||||||
using (var gs = new GZipStream(reader.BaseStream, CompressionMode.Decompress))
|
|
||||||
{
|
|
||||||
gs.CopyTo(stream);
|
|
||||||
}
|
|
||||||
stream.Position = 0;
|
|
||||||
using (var binaryReader = new BinaryReader(stream))
|
|
||||||
{
|
|
||||||
ReadWebData(binaryReader);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
reader.Position = 0x20;
|
|
||||||
magic = reader.ReadBytes(6);
|
|
||||||
reader.Position = 0;
|
|
||||||
if (brotliMagic.SequenceEqual(magic))
|
|
||||||
{
|
|
||||||
var brotliStream = new BrotliInputStream(reader.BaseStream);
|
|
||||||
var stream = new MemoryStream();
|
|
||||||
brotliStream.CopyTo(stream);
|
|
||||||
stream.Position = 0;
|
|
||||||
using (var binaryReader = new BinaryReader(stream))
|
|
||||||
{
|
|
||||||
ReadWebData(binaryReader);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
reader.endian = EndianType.LittleEndian;
|
|
||||||
ReadWebData(reader);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ReadWebData(BinaryReader reader)
|
|
||||||
{
|
|
||||||
var signature = reader.ReadStringToNull();
|
var signature = reader.ReadStringToNull();
|
||||||
if (signature != "UnityWebData1.0")
|
|
||||||
return;
|
|
||||||
var headLength = reader.ReadInt32();
|
var headLength = reader.ReadInt32();
|
||||||
var dataList = new List<WebData>();
|
var dataList = new List<WebData>();
|
||||||
while (reader.BaseStream.Position < headLength)
|
while (reader.BaseStream.Position < headLength)
|
||||||
@@ -83,6 +35,7 @@ namespace AssetStudio
|
|||||||
{
|
{
|
||||||
var data = dataList[i];
|
var data = dataList[i];
|
||||||
var file = new StreamFile();
|
var file = new StreamFile();
|
||||||
|
file.path = data.path;
|
||||||
file.fileName = Path.GetFileName(data.path);
|
file.fileName = Path.GetFileName(data.path);
|
||||||
reader.BaseStream.Position = data.dataOffset;
|
reader.BaseStream.Position = data.dataOffset;
|
||||||
file.stream = new MemoryStream(reader.ReadBytes(data.dataLength));
|
file.stream = new MemoryStream(reader.ReadBytes(data.dataLength));
|
||||||
|
|||||||
114
AssetStudioCLI/AssetStudioCLI.csproj
Normal file
114
AssetStudioCLI/AssetStudioCLI.csproj
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFrameworks>net472;net6.0;net7.0;net8.0</TargetFrameworks>
|
||||||
|
<AssemblyTitle>ArknightsStudio by aelurum</AssemblyTitle>
|
||||||
|
<AssemblyName>ArknightsStudioCLI</AssemblyName>
|
||||||
|
<Version>1.1.0</Version>
|
||||||
|
<Copyright>Copyright © Perfare; Copyright © aelurum 2023</Copyright>
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>embedded</DebugType>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\AssetStudioUtility\AssetStudioUtility.csproj" />
|
||||||
|
<ProjectReference Include="..\AssetStudio\AssetStudio.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- Use local compiled win-x86 and win-x64 Texture2DDecoder libs, because libs from Kyaru.Texture2DDecoder.Windows were compiled with /MD flag -->
|
||||||
|
|
||||||
|
<Target Name="CopyExtraFilesPortable" AfterTargets="AfterBuild" Condition=" '$(RuntimeIdentifier)' == '' ">
|
||||||
|
<Message Text="Copying windows extra files for $(TargetFramework)... " Importance="high" />
|
||||||
|
<Copy SourceFiles="$(SolutionDir)AssetStudioFBXNative\bin\Win32\$(Configuration)\AssetStudioFBXNative.dll" DestinationFolder="$(TargetDir)runtimes\win-x86\native" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(SolutionDir)AssetStudioFBXNative\bin\x64\$(Configuration)\AssetStudioFBXNative.dll" DestinationFolder="$(TargetDir)runtimes\win-x64\native" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(SolutionDir)Texture2DDecoderNative\bin\Win32\$(Configuration)\Texture2DDecoderNative.dll" DestinationFolder="$(TargetDir)runtimes\win-x86\native" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(SolutionDir)Texture2DDecoderNative\bin\x64\$(Configuration)\Texture2DDecoderNative.dll" DestinationFolder="$(TargetDir)runtimes\win-x64\native" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(ProjectDir)Libraries\win-x86\fmod.dll" DestinationFolder="$(TargetDir)runtimes\win-x86\native" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(ProjectDir)Libraries\win-x64\fmod.dll" DestinationFolder="$(TargetDir)runtimes\win-x64\native" ContinueOnError="false" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="CopyExtraFilesPortableNet" AfterTargets="AfterBuild" Condition=" '$(RuntimeIdentifier)' == '' AND '$(TargetFramework)' != 'net472' ">
|
||||||
|
<Message Text="Copying other platforms extra files for $(TargetFramework)... " Importance="high" />
|
||||||
|
<Copy SourceFiles="$(ProjectDir)Libraries\linux-x64\libAssetStudioFBXNative.so" DestinationFolder="$(TargetDir)runtimes\linux-x64\native" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(ProjectDir)Libraries\osx-x64\libAssetStudioFBXNative.dylib" DestinationFolder="$(TargetDir)runtimes\osx-x64\native" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(ProjectDir)Libraries\osx-arm64\libAssetStudioFBXNative.dylib" DestinationFolder="$(TargetDir)runtimes\osx-arm64\native" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(ProjectDir)Libraries\linux-x86\libfmod.so" DestinationFolder="$(TargetDir)runtimes\linux-x86\native" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(ProjectDir)Libraries\linux-x64\libfmod.so" DestinationFolder="$(TargetDir)runtimes\linux-x64\native" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(ProjectDir)Libraries\osx-x64\libfmod.dylib" DestinationFolder="$(TargetDir)runtimes\osx-x64\native" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(ProjectDir)Libraries\osx-arm64\libfmod.dylib" DestinationFolder="$(TargetDir)runtimes\osx-arm64\native" ContinueOnError="false" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<!-- Publishing an app as framework-dependent produces a cross-platform binary as a dll file, and a platform-specific executable that targets your current platform.
|
||||||
|
The dll is cross-platform while the executable isn't -->
|
||||||
|
<Target Name="PublishExtraFilesPortable" AfterTargets="Publish" Condition=" '$(RuntimeIdentifier)' == '' ">
|
||||||
|
<Message Text="Publishing windows extra files for Portable build ($(TargetFramework))... " Importance="high" />
|
||||||
|
<Copy SourceFiles="$(TargetDir)runtimes\win-x86\native\AssetStudioFBXNative.dll" DestinationFolder="$(PublishDir)runtimes\win-x86\native" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(TargetDir)runtimes\win-x64\native\AssetStudioFBXNative.dll" DestinationFolder="$(PublishDir)runtimes\win-x64\native" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(TargetDir)runtimes\win-x86\native\Texture2DDecoderNative.dll" DestinationFolder="$(PublishDir)runtimes\win-x86\native" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(TargetDir)runtimes\win-x64\native\Texture2DDecoderNative.dll" DestinationFolder="$(PublishDir)runtimes\win-x64\native" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(TargetDir)runtimes\win-x86\native\fmod.dll" DestinationFolder="$(PublishDir)runtimes\win-x86\native" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(TargetDir)runtimes\win-x64\native\fmod.dll" DestinationFolder="$(PublishDir)runtimes\win-x64\native" ContinueOnError="false" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="PublishExtraFilesPortableNet" AfterTargets="Publish" Condition=" '$(RuntimeIdentifier)' == '' AND '$(TargetFramework)' != 'net472' ">
|
||||||
|
<Message Text="Publishing other platforms extra files for Portable build ($(TargetFramework))... " Importance="high" />
|
||||||
|
<Copy SourceFiles="$(TargetDir)runtimes\linux-x64\native\libAssetStudioFBXNative.so" DestinationFolder="$(PublishDir)runtimes\linux-x64\native" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(TargetDir)runtimes\osx-x64\native\libAssetStudioFBXNative.dylib" DestinationFolder="$(PublishDir)runtimes\osx-x64\native" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(TargetDir)runtimes\osx-arm64\native\libAssetStudioFBXNative.dylib" DestinationFolder="$(PublishDir)runtimes\osx-arm64\native" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(TargetDir)runtimes\linux-x86\native\libfmod.so" DestinationFolder="$(PublishDir)runtimes\linux-x86\native" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(TargetDir)runtimes\linux-x64\native\libfmod.so" DestinationFolder="$(PublishDir)runtimes\linux-x64\native" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(TargetDir)runtimes\osx-x64\native\libfmod.dylib" DestinationFolder="$(PublishDir)runtimes\osx-x64\native" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(TargetDir)runtimes\osx-arm64\native\libfmod.dylib" DestinationFolder="$(PublishDir)runtimes\osx-arm64\native" ContinueOnError="false" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="CopyExtraFilesWin86" AfterTargets="AfterBuild" Condition=" '$(RuntimeIdentifier)' == 'win-x86' ">
|
||||||
|
<Message Text="Copying extra files for $(RuntimeIdentifier)($(TargetFramework))... " Importance="high" />
|
||||||
|
<Copy SourceFiles="$(SolutionDir)AssetStudioFBXNative\bin\Win32\$(Configuration)\AssetStudioFBXNative.dll" DestinationFolder="$(TargetDir)" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(SolutionDir)Texture2DDecoderNative\bin\Win32\$(Configuration)\Texture2DDecoderNative.dll" DestinationFolder="$(TargetDir)" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(ProjectDir)Libraries\win-x86\fmod.dll" DestinationFolder="$(TargetDir)" ContinueOnError="false" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="CopyExtraFilesWin64" AfterTargets="AfterBuild" Condition=" '$(RuntimeIdentifier)' == 'win-x64' ">
|
||||||
|
<Message Text="Copying extra files for $(RuntimeIdentifier)($(TargetFramework))... " Importance="high" />
|
||||||
|
<Copy SourceFiles="$(SolutionDir)AssetStudioFBXNative\bin\x64\$(Configuration)\AssetStudioFBXNative.dll" DestinationFolder="$(TargetDir)" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(SolutionDir)Texture2DDecoderNative\bin\x64\$(Configuration)\Texture2DDecoderNative.dll" DestinationFolder="$(TargetDir)" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(ProjectDir)Libraries\win-x64\fmod.dll" DestinationFolder="$(TargetDir)" ContinueOnError="false" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="PublishExtraFilesWin" AfterTargets="Publish" Condition=" $(RuntimeIdentifier.Contains('win-x')) ">
|
||||||
|
<Message Text="Publishing extra files for $(RuntimeIdentifier)($(TargetFramework))... " Importance="high" />
|
||||||
|
<Copy SourceFiles="$(TargetDir)\AssetStudioFBXNative.dll" DestinationFolder="$(PublishDir)" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(TargetDir)\Texture2DDecoderNative.dll" DestinationFolder="$(PublishDir)" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(TargetDir)\fmod.dll" DestinationFolder="$(PublishDir)" ContinueOnError="false" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="CopyExtraFilesLinux64" AfterTargets="AfterBuild" Condition=" '$(RuntimeIdentifier)' == 'linux-x64' ">
|
||||||
|
<Message Text="Copying extra files for $(RuntimeIdentifier)($(TargetFramework))... " Importance="high" />
|
||||||
|
<Copy SourceFiles="$(ProjectDir)Libraries\linux-x64\libAssetStudioFBXNative.so" DestinationFolder="$(TargetDir)" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(ProjectDir)Libraries\linux-x64\libfmod.so" DestinationFolder="$(TargetDir)" ContinueOnError="false" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="PublishExtraFilesLinux64" AfterTargets="Publish" Condition=" '$(RuntimeIdentifier)' == 'linux-x64' ">
|
||||||
|
<Message Text="Publishing extra files for $(RuntimeIdentifier)($(TargetFramework))... " Importance="high" />
|
||||||
|
<Copy SourceFiles="$(TargetDir)\libAssetStudioFBXNative.so" DestinationFolder="$(PublishDir)" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(TargetDir)\libfmod.so" DestinationFolder="$(PublishDir)" ContinueOnError="false" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="CopyExtraFilesMac" AfterTargets="AfterBuild" Condition=" $(RuntimeIdentifier.Contains('osx-')) ">
|
||||||
|
<Message Text="Copying extra files for $(RuntimeIdentifier)($(TargetFramework))... " Importance="high" />
|
||||||
|
<Copy SourceFiles="$(ProjectDir)Libraries\$(RuntimeIdentifier)\libAssetStudioFBXNative.dylib" DestinationFolder="$(TargetDir)" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(ProjectDir)Libraries\$(RuntimeIdentifier)\libfmod.dylib" DestinationFolder="$(TargetDir)" ContinueOnError="false" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="PublishExtraFilesMac" AfterTargets="Publish" Condition=" $(RuntimeIdentifier.Contains('osx-')) ">
|
||||||
|
<Message Text="Publishing extra files for $(RuntimeIdentifier)($(TargetFramework))... " Importance="high" />
|
||||||
|
<Copy SourceFiles="$(TargetDir)\libAssetStudioFBXNative.dylib" DestinationFolder="$(PublishDir)" ContinueOnError="false" />
|
||||||
|
<Copy SourceFiles="$(TargetDir)\libfmod.dylib" DestinationFolder="$(PublishDir)" ContinueOnError="false" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
</Project>
|
||||||
119
AssetStudioCLI/CLILogger.cs
Normal file
119
AssetStudioCLI/CLILogger.cs
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
using AssetStudio;
|
||||||
|
using AssetStudioCLI.Options;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace AssetStudioCLI
|
||||||
|
{
|
||||||
|
internal enum LogOutputMode
|
||||||
|
{
|
||||||
|
Console,
|
||||||
|
File,
|
||||||
|
Both,
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class CLILogger : ILogger
|
||||||
|
{
|
||||||
|
private readonly LogOutputMode logOutput;
|
||||||
|
private readonly LoggerEvent logMinLevel;
|
||||||
|
public string LogName;
|
||||||
|
public string LogPath;
|
||||||
|
|
||||||
|
public CLILogger()
|
||||||
|
{
|
||||||
|
logOutput = CLIOptions.o_logOutput.Value;
|
||||||
|
logMinLevel = CLIOptions.o_logLevel.Value;
|
||||||
|
var appAssembly = typeof(Program).Assembly.GetName();
|
||||||
|
LogName = $"{appAssembly.Name}_{DateTime.Now:yyyy-MM-dd_HH-mm-ss}.log";
|
||||||
|
LogPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, LogName);
|
||||||
|
var arch = Environment.Is64BitProcess ? "x64" : "x32";
|
||||||
|
Console.OutputEncoding = System.Text.Encoding.UTF8;
|
||||||
|
|
||||||
|
LogToFile(LoggerEvent.Verbose, $"---{appAssembly.Name} v{appAssembly.Version} [{arch}] | Logger launched---\n" +
|
||||||
|
$"CMD Args: {string.Join(" ", CLIOptions.cliArgs)}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string ColorLogLevel(LoggerEvent logLevel)
|
||||||
|
{
|
||||||
|
var formattedLevel = $"[{logLevel}]";
|
||||||
|
switch (logLevel)
|
||||||
|
{
|
||||||
|
case LoggerEvent.Info:
|
||||||
|
return $"{formattedLevel.Color(ColorConsole.BrightCyan)}";
|
||||||
|
case LoggerEvent.Warning:
|
||||||
|
return $"{formattedLevel.Color(ColorConsole.BrightYellow)}";
|
||||||
|
case LoggerEvent.Error:
|
||||||
|
return $"{formattedLevel.Color(ColorConsole.BrightRed)}";
|
||||||
|
default:
|
||||||
|
return formattedLevel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string FormatMessage(LoggerEvent logMsgLevel, string message, bool consoleMode = false)
|
||||||
|
{
|
||||||
|
var curTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||||
|
message = message.TrimEnd();
|
||||||
|
var multiLine = message.Contains('\n');
|
||||||
|
|
||||||
|
string formattedMessage;
|
||||||
|
if (consoleMode)
|
||||||
|
{
|
||||||
|
var colorLogLevel = ColorLogLevel(logMsgLevel);
|
||||||
|
formattedMessage = $"{colorLogLevel} {message}";
|
||||||
|
if (multiLine)
|
||||||
|
{
|
||||||
|
formattedMessage = formattedMessage.Replace("\n", $"\n{colorLogLevel} ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
message = Regex.Replace(message, @"\e\[[0-9;]*m(?:\e\[K)?", ""); //Delete ANSI colors
|
||||||
|
var logLevel = $"{logMsgLevel.ToString().ToUpper(),-7}";
|
||||||
|
formattedMessage = $"{curTime} | {logLevel} | {message}";
|
||||||
|
if (multiLine)
|
||||||
|
{
|
||||||
|
formattedMessage = formattedMessage.Replace("\n", $"\n{curTime} | {logLevel} | ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return formattedMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LogToConsole(LoggerEvent logMsgLevel, string message)
|
||||||
|
{
|
||||||
|
if (logOutput != LogOutputMode.File)
|
||||||
|
{
|
||||||
|
Console.WriteLine(FormatMessage(logMsgLevel, message, consoleMode: true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void LogToFile(LoggerEvent logMsgLevel, string message)
|
||||||
|
{
|
||||||
|
if (logOutput != LogOutputMode.Console)
|
||||||
|
{
|
||||||
|
using (var sw = new StreamWriter(LogPath, append: true, System.Text.Encoding.UTF8))
|
||||||
|
{
|
||||||
|
await sw.WriteLineAsync(FormatMessage(logMsgLevel, message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Log(LoggerEvent logMsgLevel, string message, bool ignoreLevel)
|
||||||
|
{
|
||||||
|
if ((logMsgLevel < logMinLevel && !ignoreLevel) || string.IsNullOrEmpty(message))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (logOutput != LogOutputMode.File)
|
||||||
|
{
|
||||||
|
LogToConsole(logMsgLevel, message);
|
||||||
|
}
|
||||||
|
if (logOutput != LogOutputMode.Console)
|
||||||
|
{
|
||||||
|
LogToFile(logMsgLevel, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
228
AssetStudioCLI/Components/Arknights/AkSpriteHelper.cs
Normal file
228
AssetStudioCLI/Components/Arknights/AkSpriteHelper.cs
Normal file
@@ -0,0 +1,228 @@
|
|||||||
|
using Arknights.PortraitSpriteMono;
|
||||||
|
using AssetStudio;
|
||||||
|
using AssetStudioCLI;
|
||||||
|
using AssetStudioCLI.Options;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using SixLabors.ImageSharp;
|
||||||
|
using SixLabors.ImageSharp.PixelFormats;
|
||||||
|
using SixLabors.ImageSharp.Processing;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace Arknights
|
||||||
|
{
|
||||||
|
internal static class AkSpriteHelper
|
||||||
|
{
|
||||||
|
public static Texture2D TryFindAlphaTex(AssetItem assetItem, AvgSprite avgSprite, bool isAvgSprite)
|
||||||
|
{
|
||||||
|
Sprite m_Sprite = (Sprite)assetItem.Asset;
|
||||||
|
var imgType = "arts/characters";
|
||||||
|
if (m_Sprite.m_RD.alphaTexture.m_PathID == 0)
|
||||||
|
{
|
||||||
|
if (isAvgSprite)
|
||||||
|
{
|
||||||
|
if (avgSprite?.FullAlphaTexture != null)
|
||||||
|
return avgSprite.FullAlphaTexture;
|
||||||
|
|
||||||
|
imgType = "avg/characters"; //since the avg hub was not found for some reason, let's try to find alpha tex by name
|
||||||
|
}
|
||||||
|
var spriteFullName = Path.GetFileNameWithoutExtension(assetItem.Container);
|
||||||
|
foreach (var item in Studio.loadedAssetsList)
|
||||||
|
{
|
||||||
|
if (item.Type == ClassIDType.Texture2D)
|
||||||
|
{
|
||||||
|
if (item.Container.Contains(imgType) && item.Container.Contains($"illust_{m_Sprite.m_Name}_material") && item.Text.Contains("[alpha]"))
|
||||||
|
return (Texture2D)item.Asset;
|
||||||
|
if (item.Container.Contains(imgType) && item.Container.Contains(spriteFullName) && item.Text == $"{m_Sprite.m_Name}[alpha]")
|
||||||
|
return (Texture2D)item.Asset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Image<Bgra32> AkGetImage(this Sprite m_Sprite, AvgSprite avgSprite = null, SpriteMaskMode spriteMaskMode = SpriteMaskMode.On)
|
||||||
|
{
|
||||||
|
if (m_Sprite.m_RD.texture.TryGet(out var m_Texture2D) && m_Sprite.m_RD.alphaTexture.TryGet(out var m_AlphaTexture2D) && spriteMaskMode != SpriteMaskMode.Off)
|
||||||
|
{
|
||||||
|
Image<Bgra32> tex;
|
||||||
|
Image<Bgra32> alphaTex;
|
||||||
|
|
||||||
|
if (avgSprite != null && avgSprite.IsHubParsed)
|
||||||
|
{
|
||||||
|
alphaTex = m_AlphaTexture2D.ConvertToImage(true);
|
||||||
|
if (avgSprite.IsFaceSprite)
|
||||||
|
{
|
||||||
|
var faceImage = m_Texture2D.ConvertToImage(true);
|
||||||
|
var faceAlpha = avgSprite.FaceSpriteAlphaTexture.ConvertToImage(true);
|
||||||
|
if (new Size(faceImage.Width, faceImage.Height) != avgSprite.FaceSize)
|
||||||
|
{
|
||||||
|
faceImage.Mutate(x => x.Resize(new ResizeOptions { Size = avgSprite.FaceSize, Sampler = KnownResamplers.Lanczos3, Mode = ResizeMode.Stretch }));
|
||||||
|
faceAlpha.Mutate(x => x.Resize(new ResizeOptions { Size = avgSprite.FaceSize, Sampler = KnownResamplers.Lanczos3, Mode = ResizeMode.Stretch }));
|
||||||
|
}
|
||||||
|
tex = avgSprite.FullTexture.ConvertToImage(true);
|
||||||
|
tex.Mutate(x => x.DrawImage(faceImage, avgSprite.FacePos, opacity: 1f));
|
||||||
|
alphaTex.Mutate(x => x.DrawImage(faceAlpha, avgSprite.FacePos, opacity: 1f));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tex = m_Texture2D.ConvertToImage(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tex = CutImage(m_Texture2D.ConvertToImage(false), m_Sprite.m_RD.textureRect, m_Sprite.m_RD.downscaleMultiplier);
|
||||||
|
alphaTex = CutImage(m_AlphaTexture2D.ConvertToImage(false), m_Sprite.m_RD.textureRect, m_Sprite.m_RD.downscaleMultiplier);
|
||||||
|
}
|
||||||
|
tex.ApplyRGBMask(alphaTex);
|
||||||
|
return tex;
|
||||||
|
}
|
||||||
|
else if (m_Sprite.m_RD.texture.TryGet(out m_Texture2D) && avgSprite != null && avgSprite.IsHubParsed)
|
||||||
|
{
|
||||||
|
if (!avgSprite.IsFaceSprite)
|
||||||
|
{
|
||||||
|
return m_Texture2D.ConvertToImage(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
var faceImage = m_Texture2D.ConvertToImage(true);
|
||||||
|
var tex = avgSprite.FullTexture.ConvertToImage(true);
|
||||||
|
if (new Size(faceImage.Width, faceImage.Height) != avgSprite.FaceSize)
|
||||||
|
{
|
||||||
|
faceImage.Mutate(x => x.Resize(new ResizeOptions { Size = avgSprite.FaceSize, Sampler = KnownResamplers.Lanczos3, Mode = ResizeMode.Stretch }));
|
||||||
|
}
|
||||||
|
tex.Mutate(x => x.DrawImage(faceImage, avgSprite.FacePos, opacity: 1f));
|
||||||
|
|
||||||
|
return tex;
|
||||||
|
}
|
||||||
|
else if (m_Sprite.m_RD.texture.TryGet(out m_Texture2D))
|
||||||
|
{
|
||||||
|
return CutImage(m_Texture2D.ConvertToImage(false), m_Sprite.m_RD.textureRect, m_Sprite.m_RD.downscaleMultiplier);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Image<Bgra32> AkGetImage(this PortraitSprite portraitSprite, SpriteMaskMode spriteMaskMode = SpriteMaskMode.On)
|
||||||
|
{
|
||||||
|
if (portraitSprite.Texture != null && portraitSprite.AlphaTexture != null)
|
||||||
|
{
|
||||||
|
var tex = CutImage(portraitSprite.Texture.ConvertToImage(false), portraitSprite.TextureRect, portraitSprite.DownscaleMultiplier, portraitSprite.Rotate);
|
||||||
|
|
||||||
|
if (spriteMaskMode == SpriteMaskMode.Off)
|
||||||
|
{
|
||||||
|
return tex;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var alphaTex = CutImage(portraitSprite.AlphaTexture.ConvertToImage(false), portraitSprite.TextureRect, portraitSprite.DownscaleMultiplier, portraitSprite.Rotate);
|
||||||
|
tex.ApplyRGBMask(alphaTex);
|
||||||
|
return tex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<PortraitSprite> GeneratePortraits(AssetItem asset)
|
||||||
|
{
|
||||||
|
var portraits = new List<PortraitSprite>();
|
||||||
|
|
||||||
|
var portraitsDict = ((MonoBehaviour)asset.Asset).ToType();
|
||||||
|
if (portraitsDict == null)
|
||||||
|
{
|
||||||
|
Logger.Warning("Portraits MonoBehaviour is not readable.");
|
||||||
|
return portraits;
|
||||||
|
}
|
||||||
|
var portraitsJson = JsonConvert.SerializeObject(portraitsDict);
|
||||||
|
var portraitsData = JsonConvert.DeserializeObject<PortraitSpriteConfig>(portraitsJson);
|
||||||
|
|
||||||
|
var atlasTex = (Texture2D)Studio.loadedAssetsList.Find(x => x.m_PathID == portraitsData._atlas.Texture.m_PathID).Asset;
|
||||||
|
var atlasAlpha = (Texture2D)Studio.loadedAssetsList.Find(x => x.m_PathID == portraitsData._atlas.Alpha.m_PathID).Asset;
|
||||||
|
|
||||||
|
foreach (var portraitData in portraitsData._sprites)
|
||||||
|
{
|
||||||
|
var portraitSprite = new PortraitSprite()
|
||||||
|
{
|
||||||
|
Name = portraitData.Name,
|
||||||
|
AssetsFile = atlasTex.assetsFile,
|
||||||
|
Container = asset.Container,
|
||||||
|
Texture = atlasTex,
|
||||||
|
AlphaTexture = atlasAlpha,
|
||||||
|
TextureRect = new Rectf(portraitData.Rect.X, portraitData.Rect.Y, portraitData.Rect.W, portraitData.Rect.H),
|
||||||
|
Rotate = portraitData.Rotate,
|
||||||
|
};
|
||||||
|
portraits.Add(portraitSprite);
|
||||||
|
}
|
||||||
|
|
||||||
|
return portraits;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ApplyRGBMask(this Image<Bgra32> tex, Image<Bgra32> texMask)
|
||||||
|
{
|
||||||
|
using (texMask)
|
||||||
|
{
|
||||||
|
bool resized = false;
|
||||||
|
if (tex.Width != texMask.Width || tex.Height != texMask.Height)
|
||||||
|
{
|
||||||
|
texMask.Mutate(x => x.Resize(tex.Width, tex.Height, CLIOptions.o_akAlphaTexResampler.Value));
|
||||||
|
resized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var invGamma = 1.0 / (1.0 + CLIOptions.o_akShadowGamma.Value / 10.0);
|
||||||
|
if (CLIOptions.akResizedOnly && !resized)
|
||||||
|
{
|
||||||
|
invGamma = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
tex.ProcessPixelRows(texMask, (sourceTex, targetTexMask) =>
|
||||||
|
{
|
||||||
|
for (int y = 0; y < texMask.Height; y++)
|
||||||
|
{
|
||||||
|
var texRow = sourceTex.GetRowSpan(y);
|
||||||
|
var maskRow = targetTexMask.GetRowSpan(y);
|
||||||
|
for (int x = 0; x < maskRow.Length; x++)
|
||||||
|
{
|
||||||
|
var grayscale = (maskRow[x].R + maskRow[x].G + maskRow[x].B) / 3.0;
|
||||||
|
if (invGamma != 1.0)
|
||||||
|
{
|
||||||
|
grayscale = 255 - Math.Pow((255 - grayscale) / 255, invGamma) * 255;
|
||||||
|
}
|
||||||
|
texRow[x].A = (byte)grayscale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Image<Bgra32> CutImage(Image<Bgra32> originalImage, Rectf textureRect, float downscaleMultiplier, bool rotate = false)
|
||||||
|
{
|
||||||
|
if (originalImage != null)
|
||||||
|
{
|
||||||
|
if (downscaleMultiplier > 0f && downscaleMultiplier != 1f)
|
||||||
|
{
|
||||||
|
var newSize = (Size)(new Size(originalImage.Width, originalImage.Height) / downscaleMultiplier);
|
||||||
|
originalImage.Mutate(x => x.Resize(newSize, KnownResamplers.Lanczos3, compand: true));
|
||||||
|
}
|
||||||
|
var rectX = (int)Math.Floor(textureRect.x);
|
||||||
|
var rectY = (int)Math.Floor(textureRect.y);
|
||||||
|
var rectRight = (int)Math.Ceiling(textureRect.x + textureRect.width);
|
||||||
|
var rectBottom = (int)Math.Ceiling(textureRect.y + textureRect.height);
|
||||||
|
rectRight = Math.Min(rectRight, originalImage.Width);
|
||||||
|
rectBottom = Math.Min(rectBottom, originalImage.Height);
|
||||||
|
var rect = new Rectangle(rectX, rectY, rectRight - rectX, rectBottom - rectY);
|
||||||
|
var spriteImage = originalImage.Clone(x => x.Crop(rect));
|
||||||
|
originalImage.Dispose();
|
||||||
|
if (rotate)
|
||||||
|
{
|
||||||
|
spriteImage.Mutate(x => x.Rotate(RotateMode.Rotate270));
|
||||||
|
}
|
||||||
|
spriteImage.Mutate(x => x.Flip(FlipMode.Vertical));
|
||||||
|
|
||||||
|
return spriteImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
126
AssetStudioCLI/Components/Arknights/AvgSprite.cs
Normal file
126
AssetStudioCLI/Components/Arknights/AvgSprite.cs
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
using Arknights.AvgCharHubMono;
|
||||||
|
using AssetStudio;
|
||||||
|
using AssetStudioCLI;
|
||||||
|
using SixLabors.ImageSharp;
|
||||||
|
using System.Linq;
|
||||||
|
using System;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Arknights
|
||||||
|
{
|
||||||
|
internal class AvgSprite
|
||||||
|
{
|
||||||
|
public Texture2D FaceSpriteAlphaTexture { get; }
|
||||||
|
public Texture2D FullTexture { get; }
|
||||||
|
public Texture2D FullAlphaTexture { get; }
|
||||||
|
public Point FacePos { get; }
|
||||||
|
public Size FaceSize { get; }
|
||||||
|
public string Alias { get; }
|
||||||
|
public bool IsWholeBodySprite { get; }
|
||||||
|
public bool IsFaceSprite { get; }
|
||||||
|
public bool IsHubParsed { get; }
|
||||||
|
|
||||||
|
private AvgSpriteConfig GetCurSpriteGroup(AvgSpriteConfigGroup spriteHubDataGrouped, long spriteItemID, string spriteName)
|
||||||
|
{
|
||||||
|
if (spriteHubDataGrouped.SpriteGroups.Length > 1)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(spriteName))
|
||||||
|
{
|
||||||
|
var groupFromName = int.TryParse(spriteName?.Substring(spriteName.IndexOf('$') + 1, 1), out int groupIndex);
|
||||||
|
if (groupFromName)
|
||||||
|
{
|
||||||
|
return spriteHubDataGrouped.SpriteGroups[groupIndex - 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return spriteHubDataGrouped.SpriteGroups.FirstOrDefault(x => x.Sprites.Any(y => y.Sprite.m_PathID == spriteItemID));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return spriteHubDataGrouped.SpriteGroups[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool TryGetSpriteHub(AssetItem assetItem, out AvgSpriteConfig spriteHubData)
|
||||||
|
{
|
||||||
|
spriteHubData = null;
|
||||||
|
var avgSpriteHubItem = Studio.loadedAssetsList.Find(x =>
|
||||||
|
x.Type == ClassIDType.MonoBehaviour
|
||||||
|
&& x.Container == assetItem.Container
|
||||||
|
&& x.Text.IndexOf("AVGCharacterSpriteHub", StringComparison.OrdinalIgnoreCase) >= 0
|
||||||
|
);
|
||||||
|
if (avgSpriteHubItem == null)
|
||||||
|
{
|
||||||
|
Logger.Warning("AVGCharacterSpriteHub was not found.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var spriteHubDict = ((MonoBehaviour)avgSpriteHubItem.Asset).ToType();
|
||||||
|
if (spriteHubDict == null)
|
||||||
|
{
|
||||||
|
Logger.Warning("AVGCharacterSpriteHub is not readable.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var spriteHubJson = JsonConvert.SerializeObject(spriteHubDict);
|
||||||
|
if (avgSpriteHubItem.Text.ToLower().Contains("hubgroup"))
|
||||||
|
{
|
||||||
|
var groupedSpriteHub = JsonConvert.DeserializeObject<AvgSpriteConfigGroup>(spriteHubJson);
|
||||||
|
spriteHubData = GetCurSpriteGroup(groupedSpriteHub, assetItem.m_PathID, assetItem.Text);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
spriteHubData = JsonConvert.DeserializeObject<AvgSpriteConfig>(spriteHubJson);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AvgSprite(AssetItem assetItem)
|
||||||
|
{
|
||||||
|
if (TryGetSpriteHub(assetItem, out var spriteHubData))
|
||||||
|
{
|
||||||
|
IsHubParsed = spriteHubData?.Sprites.Length > 0;
|
||||||
|
}
|
||||||
|
if (IsHubParsed)
|
||||||
|
{
|
||||||
|
var curSpriteData = spriteHubData.Sprites.FirstOrDefault(x => x.Sprite.m_PathID == assetItem.m_PathID);
|
||||||
|
|
||||||
|
if (curSpriteData == null)
|
||||||
|
{
|
||||||
|
Logger.Warning($"Sprite \"{assetItem.Text}\" was not found in the avg sprite hub");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Alias = curSpriteData.Alias;
|
||||||
|
IsWholeBodySprite = curSpriteData.IsWholeBody;
|
||||||
|
|
||||||
|
if (spriteHubData.FaceSize.X > 0 && spriteHubData.FaceSize.Y > 0) //If face data exist
|
||||||
|
{
|
||||||
|
var fullTexSpriteData = spriteHubData.Sprites.Last(); //Last sprite item in the list usually contains PathID of Sprite with full texture
|
||||||
|
|
||||||
|
var curSprite = (Sprite)assetItem.Asset;
|
||||||
|
IsFaceSprite = curSprite.m_Rect.width <= 256 && curSprite.m_Rect.height <= 256 && curSprite.m_PathID != fullTexSpriteData.Sprite.m_PathID;
|
||||||
|
|
||||||
|
var curSpriteAlphaID = curSpriteData.AlphaTex.m_PathID;
|
||||||
|
var curSpriteAlphaTex = (Texture2D)Studio.loadedAssetsList.Find(x => x.m_PathID == curSpriteAlphaID)?.Asset;
|
||||||
|
if (curSpriteAlphaTex != null)
|
||||||
|
{
|
||||||
|
FaceSpriteAlphaTexture = IsFaceSprite ? curSpriteAlphaTex : null;
|
||||||
|
fullTexSpriteData = IsFaceSprite ? fullTexSpriteData : curSpriteData;
|
||||||
|
}
|
||||||
|
var fullTexSpriteID = fullTexSpriteData.Sprite.m_PathID;
|
||||||
|
var fullTexAlphaID = fullTexSpriteData.AlphaTex.m_PathID;
|
||||||
|
var fullTexSprite = (Sprite)Studio.loadedAssetsList.Find(x => x.m_PathID == fullTexSpriteID).Asset;
|
||||||
|
|
||||||
|
FullTexture = fullTexSprite.m_RD.texture.TryGet(out var fullTex) ? fullTex : null;
|
||||||
|
FullAlphaTexture = (Texture2D)Studio.loadedAssetsList.Find(x => x.m_PathID == fullTexAlphaID)?.Asset;
|
||||||
|
FacePos = new Point((int)Math.Round(spriteHubData.FacePos.X), (int)Math.Round(spriteHubData.FacePos.Y));
|
||||||
|
FaceSize = new Size((int)Math.Round(spriteHubData.FaceSize.X), (int)Math.Round(spriteHubData.FaceSize.Y));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FullAlphaTexture = (Texture2D)Studio.loadedAssetsList.Find(x => x.m_PathID == curSpriteData.AlphaTex.m_PathID).Asset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
30
AssetStudioCLI/Components/Arknights/AvgSpriteConfig.cs
Normal file
30
AssetStudioCLI/Components/Arknights/AvgSpriteConfig.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using AssetStudio;
|
||||||
|
|
||||||
|
namespace Arknights.AvgCharHubMono
|
||||||
|
{
|
||||||
|
internal class AvgAssetIDs
|
||||||
|
{
|
||||||
|
public int m_FileID { get; set; }
|
||||||
|
public long m_PathID { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class AvgSpriteData
|
||||||
|
{
|
||||||
|
public AvgAssetIDs Sprite { get; set; }
|
||||||
|
public AvgAssetIDs AlphaTex { get; set; }
|
||||||
|
public string Alias { get; set; }
|
||||||
|
public bool IsWholeBody { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class AvgSpriteConfig
|
||||||
|
{
|
||||||
|
public AvgSpriteData[] Sprites { get; set; }
|
||||||
|
public Vector2 FaceSize { get; set; }
|
||||||
|
public Vector3 FacePos { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class AvgSpriteConfigGroup
|
||||||
|
{
|
||||||
|
public AvgSpriteConfig[] SpriteGroups { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
24
AssetStudioCLI/Components/Arknights/PortraitSprite.cs
Normal file
24
AssetStudioCLI/Components/Arknights/PortraitSprite.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using AssetStudio;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Arknights
|
||||||
|
{
|
||||||
|
internal class PortraitSprite
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public ClassIDType Type { get; }
|
||||||
|
public SerializedFile AssetsFile { get; set; }
|
||||||
|
public string Container { get; set; }
|
||||||
|
public Texture2D Texture { get; set; }
|
||||||
|
public Texture2D AlphaTexture { get; set; }
|
||||||
|
public Rectf TextureRect { get; set; }
|
||||||
|
public bool Rotate { get; set; }
|
||||||
|
public float DownscaleMultiplier { get; }
|
||||||
|
|
||||||
|
public PortraitSprite()
|
||||||
|
{
|
||||||
|
Type = ClassIDType.AkPortraitSprite;
|
||||||
|
DownscaleMultiplier = 1f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
41
AssetStudioCLI/Components/Arknights/PortraitSpriteConfig.cs
Normal file
41
AssetStudioCLI/Components/Arknights/PortraitSpriteConfig.cs
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
namespace Arknights.PortraitSpriteMono
|
||||||
|
{
|
||||||
|
internal class PortraitRect
|
||||||
|
{
|
||||||
|
public float X { get; set; }
|
||||||
|
public float Y { get; set; }
|
||||||
|
public float W { get; set; }
|
||||||
|
public float H { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class AtlasSprite
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Guid { get; set; }
|
||||||
|
public int Atlas { get; set; }
|
||||||
|
public PortraitRect Rect { get; set; }
|
||||||
|
public bool Rotate { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class TextureIDs
|
||||||
|
{
|
||||||
|
public int m_FileID { get; set; }
|
||||||
|
public long m_PathID { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class AtlasInfo
|
||||||
|
{
|
||||||
|
public int Index { get; set; }
|
||||||
|
public TextureIDs Texture { get; set; }
|
||||||
|
public TextureIDs Alpha { get; set; }
|
||||||
|
public int Size { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class PortraitSpriteConfig
|
||||||
|
{
|
||||||
|
public string m_Name { get; set; }
|
||||||
|
public AtlasSprite[] _sprites { get; set; }
|
||||||
|
public AtlasInfo _atlas { get; set; }
|
||||||
|
public int _index { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
42
AssetStudioCLI/Components/AssetItem.cs
Normal file
42
AssetStudioCLI/Components/AssetItem.cs
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
using Arknights;
|
||||||
|
using AssetStudio;
|
||||||
|
|
||||||
|
namespace AssetStudioCLI
|
||||||
|
{
|
||||||
|
internal class AssetItem
|
||||||
|
{
|
||||||
|
public Object Asset;
|
||||||
|
public SerializedFile SourceFile;
|
||||||
|
public string Container = string.Empty;
|
||||||
|
public string TypeString;
|
||||||
|
public long m_PathID;
|
||||||
|
public long FullSize;
|
||||||
|
public ClassIDType Type;
|
||||||
|
public string Text;
|
||||||
|
public string UniqueID;
|
||||||
|
public GameObjectNode Node;
|
||||||
|
public PortraitSprite AkPortraitSprite;
|
||||||
|
|
||||||
|
public AssetItem(Object asset)
|
||||||
|
{
|
||||||
|
Asset = asset;
|
||||||
|
SourceFile = asset.assetsFile;
|
||||||
|
Type = asset.type;
|
||||||
|
TypeString = Type.ToString();
|
||||||
|
m_PathID = asset.m_PathID;
|
||||||
|
FullSize = asset.byteSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AssetItem(PortraitSprite akPortraitSprite)
|
||||||
|
{
|
||||||
|
Asset = null;
|
||||||
|
SourceFile = akPortraitSprite.AssetsFile;
|
||||||
|
Container = akPortraitSprite.Container;
|
||||||
|
Type = akPortraitSprite.Type;
|
||||||
|
TypeString = Type.ToString();
|
||||||
|
Text = akPortraitSprite.Name;
|
||||||
|
m_PathID = -1;
|
||||||
|
AkPortraitSprite = akPortraitSprite;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
16
AssetStudioCLI/Components/BaseNode.cs
Normal file
16
AssetStudioCLI/Components/BaseNode.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using AssetStudio;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace AssetStudioCLI
|
||||||
|
{
|
||||||
|
internal class BaseNode
|
||||||
|
{
|
||||||
|
public List<BaseNode> nodes = new List<BaseNode>();
|
||||||
|
|
||||||
|
public BaseNode()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
16
AssetStudioCLI/Components/GameObjectNode.cs
Normal file
16
AssetStudioCLI/Components/GameObjectNode.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using AssetStudio;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace AssetStudioCLI
|
||||||
|
{
|
||||||
|
internal class GameObjectNode : BaseNode
|
||||||
|
{
|
||||||
|
public GameObject gameObject;
|
||||||
|
|
||||||
|
public GameObjectNode(GameObject gameObject)
|
||||||
|
{
|
||||||
|
this.gameObject = gameObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
550
AssetStudioCLI/Exporter.cs
Normal file
550
AssetStudioCLI/Exporter.cs
Normal file
@@ -0,0 +1,550 @@
|
|||||||
|
using Arknights;
|
||||||
|
using AssetStudio;
|
||||||
|
using AssetStudioCLI.Options;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using SixLabors.ImageSharp.PixelFormats;
|
||||||
|
using SixLabors.ImageSharp;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace AssetStudioCLI
|
||||||
|
{
|
||||||
|
internal static class Exporter
|
||||||
|
{
|
||||||
|
public static bool ExportTexture2D(AssetItem item, string exportPath)
|
||||||
|
{
|
||||||
|
var m_Texture2D = (Texture2D)item.Asset;
|
||||||
|
if (CLIOptions.convertTexture)
|
||||||
|
{
|
||||||
|
var type = CLIOptions.o_imageFormat.Value;
|
||||||
|
if (!TryExportFile(exportPath, item, "." + type.ToString().ToLower(), out var exportFullPath))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (CLIOptions.o_logLevel.Value <= LoggerEvent.Debug)
|
||||||
|
{
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
sb.AppendLine($"Converting \"{m_Texture2D.m_Name}\" to {type}..");
|
||||||
|
sb.AppendLine($"Width: {m_Texture2D.m_Width}");
|
||||||
|
sb.AppendLine($"Height: {m_Texture2D.m_Height}");
|
||||||
|
sb.AppendLine($"Format: {m_Texture2D.m_TextureFormat}");
|
||||||
|
switch (m_Texture2D.m_TextureSettings.m_FilterMode)
|
||||||
|
{
|
||||||
|
case 0: sb.AppendLine("Filter Mode: Point "); break;
|
||||||
|
case 1: sb.AppendLine("Filter Mode: Bilinear "); break;
|
||||||
|
case 2: sb.AppendLine("Filter Mode: Trilinear "); break;
|
||||||
|
}
|
||||||
|
sb.AppendLine($"Anisotropic level: {m_Texture2D.m_TextureSettings.m_Aniso}");
|
||||||
|
sb.AppendLine($"Mip map bias: {m_Texture2D.m_TextureSettings.m_MipBias}");
|
||||||
|
switch (m_Texture2D.m_TextureSettings.m_WrapMode)
|
||||||
|
{
|
||||||
|
case 0: sb.AppendLine($"Wrap mode: Repeat"); break;
|
||||||
|
case 1: sb.AppendLine($"Wrap mode: Clamp"); break;
|
||||||
|
}
|
||||||
|
Logger.Debug(sb.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
var image = m_Texture2D.ConvertToImage(flip: true);
|
||||||
|
if (image == null)
|
||||||
|
{
|
||||||
|
Logger.Error($"Export error. Failed to convert texture \"{m_Texture2D.m_Name}\" into image");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
using (image)
|
||||||
|
{
|
||||||
|
using (var file = File.OpenWrite(exportFullPath))
|
||||||
|
{
|
||||||
|
image.WriteToStream(file, type);
|
||||||
|
}
|
||||||
|
Logger.Debug($"{item.TypeString} \"{item.Text}\" exported to \"{exportFullPath}\"");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!TryExportFile(exportPath, item, ".tex", out var exportFullPath))
|
||||||
|
return false;
|
||||||
|
File.WriteAllBytes(exportFullPath, m_Texture2D.image_data.GetData());
|
||||||
|
Logger.Debug($"{item.TypeString} \"{item.Text}\" exported to \"{exportFullPath}\"");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool ExportAudioClip(AssetItem item, string exportPath)
|
||||||
|
{
|
||||||
|
string exportFullPath;
|
||||||
|
var m_AudioClip = (AudioClip)item.Asset;
|
||||||
|
var m_AudioData = m_AudioClip.m_AudioData.GetData();
|
||||||
|
if (m_AudioData == null || m_AudioData.Length == 0)
|
||||||
|
{
|
||||||
|
Logger.Error($"Export error. \"{item.Text}\": AudioData was not found");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var converter = new AudioClipConverter(m_AudioClip);
|
||||||
|
if (CLIOptions.o_audioFormat.Value != AudioFormat.None && converter.IsSupport)
|
||||||
|
{
|
||||||
|
if (!TryExportFile(exportPath, item, ".wav", out exportFullPath))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (CLIOptions.o_logLevel.Value <= LoggerEvent.Debug)
|
||||||
|
{
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
sb.AppendLine($"Converting \"{m_AudioClip.m_Name}\" to wav..");
|
||||||
|
sb.AppendLine(m_AudioClip.version[0] < 5 ? $"AudioClip type: {m_AudioClip.m_Type}" : $"AudioClip compression format: {m_AudioClip.m_CompressionFormat}");
|
||||||
|
sb.AppendLine($"AudioClip channel count: {m_AudioClip.m_Channels}");
|
||||||
|
sb.AppendLine($"AudioClip sample rate: {m_AudioClip.m_Frequency}");
|
||||||
|
sb.AppendLine($"AudioClip bit depth: {m_AudioClip.m_BitsPerSample}");
|
||||||
|
Logger.Debug(sb.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
var buffer = converter.ConvertToWav(m_AudioData);
|
||||||
|
if (buffer == null)
|
||||||
|
{
|
||||||
|
Logger.Error($"Export error. \"{item.Text}\": Failed to convert to Wav");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
File.WriteAllBytes(exportFullPath, buffer);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!TryExportFile(exportPath, item, converter.GetExtensionName(), out exportFullPath))
|
||||||
|
return false;
|
||||||
|
File.WriteAllBytes(exportFullPath, m_AudioData);
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger.Debug($"{item.TypeString} \"{item.Text}\" exported to \"{exportFullPath}\"");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool ExportVideoClip(AssetItem item, string exportPath)
|
||||||
|
{
|
||||||
|
var m_VideoClip = (VideoClip)item.Asset;
|
||||||
|
if (m_VideoClip.m_ExternalResources.m_Size > 0)
|
||||||
|
{
|
||||||
|
if (!TryExportFile(exportPath, item, Path.GetExtension(m_VideoClip.m_OriginalPath), out var exportFullPath))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (CLIOptions.o_logLevel.Value <= LoggerEvent.Debug)
|
||||||
|
{
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
sb.AppendLine($"VideoClip format: {m_VideoClip.m_Format}");
|
||||||
|
sb.AppendLine($"VideoClip width: {m_VideoClip.Width}");
|
||||||
|
sb.AppendLine($"VideoClip height: {m_VideoClip.Height}");
|
||||||
|
sb.AppendLine($"VideoClip frame rate: {m_VideoClip.m_FrameRate:.0##}");
|
||||||
|
sb.AppendLine($"VideoClip split alpha: {m_VideoClip.m_HasSplitAlpha}");
|
||||||
|
Logger.Debug(sb.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
m_VideoClip.m_VideoData.WriteData(exportFullPath);
|
||||||
|
Logger.Debug($"{item.TypeString} \"{item.Text}\" exported to \"{exportFullPath}\"");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool ExportMovieTexture(AssetItem item, string exportPath)
|
||||||
|
{
|
||||||
|
var m_MovieTexture = (MovieTexture)item.Asset;
|
||||||
|
if (!TryExportFile(exportPath, item, ".ogv", out var exportFullPath))
|
||||||
|
return false;
|
||||||
|
File.WriteAllBytes(exportFullPath, m_MovieTexture.m_MovieData);
|
||||||
|
|
||||||
|
Logger.Debug($"{item.TypeString} \"{item.Text}\" exported to \"{exportFullPath}\"");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool ExportShader(AssetItem item, string exportPath)
|
||||||
|
{
|
||||||
|
if (!TryExportFile(exportPath, item, ".shader", out var exportFullPath))
|
||||||
|
return false;
|
||||||
|
var m_Shader = (Shader)item.Asset;
|
||||||
|
var str = m_Shader.Convert();
|
||||||
|
File.WriteAllText(exportFullPath, str);
|
||||||
|
|
||||||
|
Logger.Debug($"{item.TypeString} \"{item.Text}\" exported to \"{exportFullPath}\"");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool ExportTextAsset(AssetItem item, string exportPath)
|
||||||
|
{
|
||||||
|
var m_TextAsset = (TextAsset)item.Asset;
|
||||||
|
var extension = ".txt";
|
||||||
|
var assetExtension = Path.GetExtension(m_TextAsset.m_Name);
|
||||||
|
if (!CLIOptions.f_notRestoreExtensionName.Value)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(assetExtension))
|
||||||
|
{
|
||||||
|
extension = "";
|
||||||
|
}
|
||||||
|
else if (!string.IsNullOrEmpty(item.Container))
|
||||||
|
{
|
||||||
|
var ext = Path.GetExtension(item.Container);
|
||||||
|
if (!string.IsNullOrEmpty(item.Container))
|
||||||
|
{
|
||||||
|
extension = ext;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!TryExportFile(exportPath, item, extension, out var exportFullPath))
|
||||||
|
return false;
|
||||||
|
File.WriteAllBytes(exportFullPath, m_TextAsset.m_Script);
|
||||||
|
|
||||||
|
Logger.Debug($"{item.TypeString} \"{item.Text}\" exported to \"{exportFullPath}\"");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool ExportMonoBehaviour(AssetItem item, string exportPath)
|
||||||
|
{
|
||||||
|
if (!TryExportFile(exportPath, item, ".json", out var exportFullPath))
|
||||||
|
return false;
|
||||||
|
var m_MonoBehaviour = (MonoBehaviour)item.Asset;
|
||||||
|
var type = m_MonoBehaviour.ToType();
|
||||||
|
if (type == null)
|
||||||
|
{
|
||||||
|
var m_Type = m_MonoBehaviour.ConvertToTypeTree(Studio.assemblyLoader);
|
||||||
|
type = m_MonoBehaviour.ToType(m_Type);
|
||||||
|
}
|
||||||
|
if (type != null)
|
||||||
|
{
|
||||||
|
var str = JsonConvert.SerializeObject(type, Formatting.Indented);
|
||||||
|
File.WriteAllText(exportFullPath, str);
|
||||||
|
|
||||||
|
Logger.Debug($"{item.TypeString} \"{item.Text}\" exported to \"{exportFullPath}\"");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool ExportFont(AssetItem item, string exportPath)
|
||||||
|
{
|
||||||
|
var m_Font = (Font)item.Asset;
|
||||||
|
if (m_Font.m_FontData != null)
|
||||||
|
{
|
||||||
|
var extension = ".ttf";
|
||||||
|
if (m_Font.m_FontData[0] == 79 && m_Font.m_FontData[1] == 84 && m_Font.m_FontData[2] == 84 && m_Font.m_FontData[3] == 79)
|
||||||
|
{
|
||||||
|
extension = ".otf";
|
||||||
|
}
|
||||||
|
if (!TryExportFile(exportPath, item, extension, out var exportFullPath))
|
||||||
|
return false;
|
||||||
|
File.WriteAllBytes(exportFullPath, m_Font.m_FontData);
|
||||||
|
|
||||||
|
Logger.Debug($"{item.TypeString} \"{item.Text}\" exported to \"{exportFullPath}\"");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool ExportSprite(AssetItem item, string exportPath)
|
||||||
|
{
|
||||||
|
Image<Bgra32> image;
|
||||||
|
AvgSprite avgSprite = null;
|
||||||
|
var alias = "";
|
||||||
|
var m_Sprite = (Sprite)item.Asset;
|
||||||
|
var type = CLIOptions.o_imageFormat.Value;
|
||||||
|
var spriteMaskMode = CLIOptions.o_akSpriteAlphaMode.Value != AkSpriteAlphaMode.None ? SpriteMaskMode.Export : SpriteMaskMode.Off;
|
||||||
|
var isCharAvgSprite = item.Container.Contains("avg/characters");
|
||||||
|
var isCharArt = item.Container.Contains("arts/characters");
|
||||||
|
|
||||||
|
if (isCharAvgSprite)
|
||||||
|
{
|
||||||
|
avgSprite = new AvgSprite(item);
|
||||||
|
|
||||||
|
if (CLIOptions.f_akAddAliases.Value && !string.IsNullOrEmpty(avgSprite.Alias))
|
||||||
|
{
|
||||||
|
alias = $"_{avgSprite.Alias}";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CLIOptions.f_akOriginalAvgNames.Value)
|
||||||
|
{
|
||||||
|
var groupedPattern = new Regex(@"^\d{1,2}\$\d{1,2}$"); // "spriteIndex$groupIndex"
|
||||||
|
var notGroupedPattern = new Regex(@"^\d{1,2}$"); // "spriteIndex"
|
||||||
|
if (groupedPattern.IsMatch(m_Sprite.m_Name) || notGroupedPattern.IsMatch(m_Sprite.m_Name))
|
||||||
|
{
|
||||||
|
var fullName = Path.GetFileNameWithoutExtension(item.Container);
|
||||||
|
item.Text = $"{fullName}#{m_Sprite.m_Name}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!TryExportFile(exportPath, item, "." + type.ToString().ToLower(), out var exportFullPath, alias))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (CLIOptions.o_akSpriteAlphaMode.Value == AkSpriteAlphaMode.SearchExternal && (isCharAvgSprite || isCharArt))
|
||||||
|
{
|
||||||
|
if (m_Sprite.m_RD.alphaTexture.IsNull)
|
||||||
|
{
|
||||||
|
var charAlphaAtlas = AkSpriteHelper.TryFindAlphaTex(item, avgSprite, isCharAvgSprite);
|
||||||
|
if (charAlphaAtlas != null)
|
||||||
|
{
|
||||||
|
m_Sprite.m_RD.alphaTexture.Set(charAlphaAtlas);
|
||||||
|
m_Sprite.akSplitAlpha = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
image = m_Sprite.AkGetImage(avgSprite, spriteMaskMode);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
image = m_Sprite.GetImage(spriteMaskMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (image != null)
|
||||||
|
{
|
||||||
|
using (image)
|
||||||
|
{
|
||||||
|
using (var file = File.OpenWrite(exportFullPath))
|
||||||
|
{
|
||||||
|
image.WriteToStream(file, type);
|
||||||
|
}
|
||||||
|
Logger.Debug($"{item.TypeString}: \"{item.Text}\" exported to \"{exportFullPath}\"");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool ExportPortraitSprite(AssetItem item, string exportPath)
|
||||||
|
{
|
||||||
|
var type = CLIOptions.o_imageFormat.Value;
|
||||||
|
var spriteMaskMode = CLIOptions.o_akSpriteAlphaMode.Value != AkSpriteAlphaMode.None ? SpriteMaskMode.Export : SpriteMaskMode.Off;
|
||||||
|
if (!TryExportFile(exportPath, item, "." + type.ToString().ToLower(), out var exportFullPath))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var image = item.AkPortraitSprite.AkGetImage(spriteMaskMode: spriteMaskMode);
|
||||||
|
if (image != null)
|
||||||
|
{
|
||||||
|
using (image)
|
||||||
|
{
|
||||||
|
using (var file = File.OpenWrite(exportFullPath))
|
||||||
|
{
|
||||||
|
image.WriteToStream(file, type);
|
||||||
|
}
|
||||||
|
Logger.Debug($"{item.TypeString} \"{item.Text}\" exported to \"{exportFullPath}\"");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool ExportRawFile(AssetItem item, string exportPath)
|
||||||
|
{
|
||||||
|
if (item.Asset == null)
|
||||||
|
{
|
||||||
|
Logger.Warning($"Raw export is not supported for \"{item.Text}\" ({item.TypeString}) file");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!TryExportFile(exportPath, item, ".dat", out var exportFullPath))
|
||||||
|
return false;
|
||||||
|
File.WriteAllBytes(exportFullPath, item.Asset.GetRawData());
|
||||||
|
|
||||||
|
Logger.Debug($"{item.TypeString} \"{item.Text}\" exported to \"{exportFullPath}\"");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ExportGameObject(GameObject gameObject, string exportPath, List<AssetItem> animationList = null)
|
||||||
|
{
|
||||||
|
var convert = animationList != null
|
||||||
|
? new ModelConverter(gameObject, CLIOptions.o_imageFormat.Value, animationList.Select(x => (AnimationClip)x.Asset).ToArray())
|
||||||
|
: new ModelConverter(gameObject, CLIOptions.o_imageFormat.Value);
|
||||||
|
exportPath = exportPath + FixFileName(gameObject.m_Name) + ".fbx";
|
||||||
|
ExportFbx(convert, exportPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ExportFbx(IImported convert, string exportPath)
|
||||||
|
{
|
||||||
|
var eulerFilter = true;
|
||||||
|
var filterPrecision = (float)0.25f;
|
||||||
|
var exportAllNodes = true;
|
||||||
|
var exportSkins = true;
|
||||||
|
var exportAnimations = true;
|
||||||
|
var exportBlendShape = true;
|
||||||
|
var castToBone = false;
|
||||||
|
var boneSize = CLIOptions.o_fbxBoneSize.Value;
|
||||||
|
var exportAllUvsAsDiffuseMaps = false;
|
||||||
|
var scaleFactor = CLIOptions.o_fbxScaleFactor.Value;
|
||||||
|
var fbxVersion = 3;
|
||||||
|
var fbxFormat = 0;
|
||||||
|
ModelExporter.ExportFbx(exportPath, convert, eulerFilter, filterPrecision,
|
||||||
|
exportAllNodes, exportSkins, exportAnimations, exportBlendShape, castToBone, boneSize, exportAllUvsAsDiffuseMaps, scaleFactor, fbxVersion, fbxFormat == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool ExportDumpFile(AssetItem item, string exportPath)
|
||||||
|
{
|
||||||
|
if (item.Asset == null)
|
||||||
|
{
|
||||||
|
Logger.Warning($"Dump is not supported for \"{item.Text}\" ({item.TypeString}) file");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!TryExportFile(exportPath, item, ".txt", out var exportFullPath))
|
||||||
|
return false;
|
||||||
|
var str = item.Asset.Dump();
|
||||||
|
if (str == null && item.Asset is MonoBehaviour m_MonoBehaviour)
|
||||||
|
{
|
||||||
|
var m_Type = m_MonoBehaviour.ConvertToTypeTree(Studio.assemblyLoader);
|
||||||
|
str = m_MonoBehaviour.Dump(m_Type);
|
||||||
|
}
|
||||||
|
if (str != null)
|
||||||
|
{
|
||||||
|
File.WriteAllText(exportFullPath, str);
|
||||||
|
Logger.Debug($"{item.TypeString} \"{item.Text}\" saved to \"{exportFullPath}\"");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool TryExportFile(string dir, AssetItem item, string extension, out string fullPath, string alias = "")
|
||||||
|
{
|
||||||
|
var fileName = FixFileName(item.Text) + alias;
|
||||||
|
fullPath = Path.Combine(dir, fileName + extension);
|
||||||
|
if (!File.Exists(fullPath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(dir);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
fullPath = Path.Combine(dir, fileName + item.UniqueID + extension);
|
||||||
|
if (!File.Exists(fullPath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(dir);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Logger.Error($"Export error. File \"{fullPath.Color(ColorConsole.BrightRed)}\" already exist");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool ExportMesh(AssetItem item, string exportPath)
|
||||||
|
{
|
||||||
|
var m_Mesh = (Mesh)item.Asset;
|
||||||
|
if (m_Mesh.m_VertexCount <= 0)
|
||||||
|
return false;
|
||||||
|
if (!TryExportFile(exportPath, item, ".obj", out var exportFullPath))
|
||||||
|
return false;
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
sb.AppendLine("g " + m_Mesh.m_Name);
|
||||||
|
|
||||||
|
#region Vertices
|
||||||
|
|
||||||
|
if (m_Mesh.m_Vertices == null || m_Mesh.m_Vertices.Length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int c = 3;
|
||||||
|
if (m_Mesh.m_Vertices.Length == m_Mesh.m_VertexCount * 4)
|
||||||
|
{
|
||||||
|
c = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int v = 0; v < m_Mesh.m_VertexCount; v++)
|
||||||
|
{
|
||||||
|
sb.Append($"v {-m_Mesh.m_Vertices[v * c]} {m_Mesh.m_Vertices[v * c + 1]} {m_Mesh.m_Vertices[v * c + 2]}\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region UV
|
||||||
|
|
||||||
|
if (m_Mesh.m_UV0?.Length > 0)
|
||||||
|
{
|
||||||
|
c = 4;
|
||||||
|
if (m_Mesh.m_UV0.Length == m_Mesh.m_VertexCount * 2)
|
||||||
|
{
|
||||||
|
c = 2;
|
||||||
|
}
|
||||||
|
else if (m_Mesh.m_UV0.Length == m_Mesh.m_VertexCount * 3)
|
||||||
|
{
|
||||||
|
c = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int v = 0; v < m_Mesh.m_VertexCount; v++)
|
||||||
|
{
|
||||||
|
sb.AppendFormat("vt {0} {1}\r\n", m_Mesh.m_UV0[v * c], m_Mesh.m_UV0[v * c + 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Normals
|
||||||
|
|
||||||
|
if (m_Mesh.m_Normals?.Length > 0)
|
||||||
|
{
|
||||||
|
if (m_Mesh.m_Normals.Length == m_Mesh.m_VertexCount * 3)
|
||||||
|
{
|
||||||
|
c = 3;
|
||||||
|
}
|
||||||
|
else if (m_Mesh.m_Normals.Length == m_Mesh.m_VertexCount * 4)
|
||||||
|
{
|
||||||
|
c = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int v = 0; v < m_Mesh.m_VertexCount; v++)
|
||||||
|
{
|
||||||
|
sb.AppendFormat("vn {0} {1} {2}\r\n", -m_Mesh.m_Normals[v * c], m_Mesh.m_Normals[v * c + 1], m_Mesh.m_Normals[v * c + 2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Face
|
||||||
|
|
||||||
|
int sum = 0;
|
||||||
|
for (var i = 0; i < m_Mesh.m_SubMeshes.Length; i++)
|
||||||
|
{
|
||||||
|
sb.AppendLine($"g {m_Mesh.m_Name}_{i}");
|
||||||
|
int indexCount = (int)m_Mesh.m_SubMeshes[i].indexCount;
|
||||||
|
var end = sum + indexCount / 3;
|
||||||
|
for (int f = sum; f < end; f++)
|
||||||
|
{
|
||||||
|
sb.AppendFormat("f {0}/{0}/{0} {1}/{1}/{1} {2}/{2}/{2}\r\n", m_Mesh.m_Indices[f * 3 + 2] + 1, m_Mesh.m_Indices[f * 3 + 1] + 1, m_Mesh.m_Indices[f * 3] + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
sum = end;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
sb.Replace("NaN", "0");
|
||||||
|
File.WriteAllText(exportFullPath, sb.ToString());
|
||||||
|
Logger.Debug($"{item.TypeString} \"{item.Text}\" exported to \"{exportFullPath}\"");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool ExportConvertFile(AssetItem item, string exportPath)
|
||||||
|
{
|
||||||
|
switch (item.Type)
|
||||||
|
{
|
||||||
|
case ClassIDType.Texture2D:
|
||||||
|
return ExportTexture2D(item, exportPath);
|
||||||
|
case ClassIDType.AudioClip:
|
||||||
|
return ExportAudioClip(item, exportPath);
|
||||||
|
case ClassIDType.VideoClip:
|
||||||
|
return ExportVideoClip(item, exportPath);
|
||||||
|
case ClassIDType.MovieTexture:
|
||||||
|
return ExportMovieTexture(item, exportPath);
|
||||||
|
case ClassIDType.Shader:
|
||||||
|
return ExportShader(item, exportPath);
|
||||||
|
case ClassIDType.TextAsset:
|
||||||
|
return ExportTextAsset(item, exportPath);
|
||||||
|
case ClassIDType.MonoBehaviour:
|
||||||
|
return ExportMonoBehaviour(item, exportPath);
|
||||||
|
case ClassIDType.Font:
|
||||||
|
return ExportFont(item, exportPath);
|
||||||
|
case ClassIDType.Sprite:
|
||||||
|
return ExportSprite(item, exportPath);
|
||||||
|
case ClassIDType.AkPortraitSprite:
|
||||||
|
return ExportPortraitSprite(item, exportPath);
|
||||||
|
case ClassIDType.Mesh:
|
||||||
|
return ExportMesh(item, exportPath);
|
||||||
|
default:
|
||||||
|
return ExportRawFile(item, exportPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string FixFileName(string str)
|
||||||
|
{
|
||||||
|
if (str.Length >= 260) return Path.GetRandomFileName();
|
||||||
|
return Path.GetInvalidFileNameChars().Aggregate(str, (current, c) => current.Replace(c, '_'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
AssetStudioCLI/Libraries/linux-x64/libAssetStudioFBXNative.so
Normal file
BIN
AssetStudioCLI/Libraries/linux-x64/libAssetStudioFBXNative.so
Normal file
Binary file not shown.
BIN
AssetStudioCLI/Libraries/linux-x64/libTexture2DDecoderNative.so
Normal file
BIN
AssetStudioCLI/Libraries/linux-x64/libTexture2DDecoderNative.so
Normal file
Binary file not shown.
BIN
AssetStudioCLI/Libraries/linux-x64/libfmod.so
Normal file
BIN
AssetStudioCLI/Libraries/linux-x64/libfmod.so
Normal file
Binary file not shown.
BIN
AssetStudioCLI/Libraries/linux-x86/libfmod.so
Normal file
BIN
AssetStudioCLI/Libraries/linux-x86/libfmod.so
Normal file
Binary file not shown.
BIN
AssetStudioCLI/Libraries/osx-arm64/libAssetStudioFBXNative.dylib
Normal file
BIN
AssetStudioCLI/Libraries/osx-arm64/libAssetStudioFBXNative.dylib
Normal file
Binary file not shown.
Binary file not shown.
BIN
AssetStudioCLI/Libraries/osx-arm64/libfmod.dylib
Normal file
BIN
AssetStudioCLI/Libraries/osx-arm64/libfmod.dylib
Normal file
Binary file not shown.
Binary file not shown.
BIN
AssetStudioCLI/Libraries/osx-x64/libTexture2DDecoderNative.dylib
Normal file
BIN
AssetStudioCLI/Libraries/osx-x64/libTexture2DDecoderNative.dylib
Normal file
Binary file not shown.
BIN
AssetStudioCLI/Libraries/osx-x64/libfmod.dylib
Normal file
BIN
AssetStudioCLI/Libraries/osx-x64/libfmod.dylib
Normal file
Binary file not shown.
BIN
AssetStudioCLI/Libraries/win-x64/fmod.dll
Normal file
BIN
AssetStudioCLI/Libraries/win-x64/fmod.dll
Normal file
Binary file not shown.
BIN
AssetStudioCLI/Libraries/win-x86/fmod.dll
Normal file
BIN
AssetStudioCLI/Libraries/win-x86/fmod.dll
Normal file
Binary file not shown.
1211
AssetStudioCLI/Options/CLIOptions.cs
Normal file
1211
AssetStudioCLI/Options/CLIOptions.cs
Normal file
File diff suppressed because it is too large
Load Diff
27
AssetStudioCLI/Options/Option.cs
Normal file
27
AssetStudioCLI/Options/Option.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
namespace AssetStudioCLI.Options
|
||||||
|
{
|
||||||
|
internal class Option<T>
|
||||||
|
{
|
||||||
|
public string Name { get; }
|
||||||
|
public string Description { get; }
|
||||||
|
public T Value { get; set; }
|
||||||
|
public T DefaultValue { get; }
|
||||||
|
public HelpGroups HelpGroup { get; }
|
||||||
|
public bool IsFlag { get; }
|
||||||
|
|
||||||
|
public Option(T optionDefaultValue, string optionName, string optionDescription, HelpGroups optionHelpGroup, bool isFlag)
|
||||||
|
{
|
||||||
|
Name = optionName;
|
||||||
|
Description = optionDescription;
|
||||||
|
DefaultValue = optionDefaultValue;
|
||||||
|
Value = DefaultValue;
|
||||||
|
HelpGroup = optionHelpGroup;
|
||||||
|
IsFlag = isFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return Value != null ? Value.ToString() : string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
17
AssetStudioCLI/Options/OptionExtensions.cs
Normal file
17
AssetStudioCLI/Options/OptionExtensions.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace AssetStudioCLI.Options
|
||||||
|
{
|
||||||
|
internal static class OptionExtensions
|
||||||
|
{
|
||||||
|
public static Action<string, string, HelpGroups, bool> OptionGrouping = (name, desc, group, isFlag) => { };
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class GroupedOption<T> : Option<T>
|
||||||
|
{
|
||||||
|
public GroupedOption(T optionDefaultValue, string optionName, string optionDescription, HelpGroups optionHelpGroup, bool isFlag = false) : base(optionDefaultValue, optionName, optionDescription, optionHelpGroup, isFlag)
|
||||||
|
{
|
||||||
|
OptionExtensions.OptionGrouping(optionName, optionDescription, optionHelpGroup, isFlag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
73
AssetStudioCLI/Program.cs
Normal file
73
AssetStudioCLI/Program.cs
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
using AssetStudio;
|
||||||
|
using AssetStudioCLI.Options;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace AssetStudioCLI
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
CLIOptions.ParseArgs(args);
|
||||||
|
if (CLIOptions.isParsed)
|
||||||
|
{
|
||||||
|
CLIRun();
|
||||||
|
}
|
||||||
|
else if (CLIOptions.showHelp)
|
||||||
|
{
|
||||||
|
CLIOptions.ShowHelp();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine();
|
||||||
|
CLIOptions.ShowHelp(showUsageOnly: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void CLIRun()
|
||||||
|
{
|
||||||
|
var cliLogger = new CLILogger();
|
||||||
|
Logger.Default = cliLogger;
|
||||||
|
CLIOptions.ShowCurrentOptions();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (Studio.LoadAssets())
|
||||||
|
{
|
||||||
|
Studio.ParseAssets();
|
||||||
|
if (CLIOptions.filterBy != FilterBy.None)
|
||||||
|
{
|
||||||
|
Studio.Filter();
|
||||||
|
}
|
||||||
|
if (CLIOptions.o_exportAssetList.Value != ExportListType.None)
|
||||||
|
{
|
||||||
|
Studio.ExportAssetList();
|
||||||
|
}
|
||||||
|
switch (CLIOptions.o_workMode.Value)
|
||||||
|
{
|
||||||
|
case WorkMode.Info:
|
||||||
|
Studio.ShowExportableAssetsInfo();
|
||||||
|
break;
|
||||||
|
case WorkMode.ExportLive2D:
|
||||||
|
Studio.ExportLive2D();
|
||||||
|
break;
|
||||||
|
case WorkMode.SplitObjects:
|
||||||
|
Studio.ExportSplitObjects();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Studio.ExportAssets();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.Error(ex.ToString());
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
cliLogger.LogToFile(LoggerEvent.Verbose, "---Program ended---");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
159
AssetStudioCLI/ReadMe.md
Normal file
159
AssetStudioCLI/ReadMe.md
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
## ArknightsStudioCLI
|
||||||
|
CLI version of ArknightsStudio.
|
||||||
|
- Supported asset types for export: `Texture2D`, `Sprite`, `AkPortraitSprite`, `TextAsset`, `MonoBehaviour`, `Font`, `Shader`, `MovieTexture`, `AudioClip`, `VideoClip`, `Mesh`.
|
||||||
|
- *There are no plans to add support for `AnimationClip`, `Animator` for now.*
|
||||||
|
|
||||||
|
### Usage
|
||||||
|
```
|
||||||
|
ArknightsStudioCLI <input path to asset file/folder> [-m, --mode <value>]
|
||||||
|
[-t, --asset-type <value(s)>] [-g, --group-option <value>]
|
||||||
|
[-o, --output <path>] [-h, --help]
|
||||||
|
[--log-level <value>] [--log-output <value>]
|
||||||
|
[--image-format <value>] [--audio-format <value>]
|
||||||
|
[--l2d-motion-mode <value>] [--l2d-force-bezier]
|
||||||
|
[--fbx-scale-factor <value>] [--fbx-bone-size <value>]
|
||||||
|
[--filter-by-name <text>] [--filter-by-container <text>]
|
||||||
|
[--filter-by-pathid <text>] [--filter-by-text <text>]
|
||||||
|
[--spritealpha-mode <value>] [--alphatex-resampler <value>]
|
||||||
|
[--shadow-gamma <value>] [--original-avg-names]
|
||||||
|
[--add-aliases] [--export-asset-list <value>]
|
||||||
|
[--assembly-folder <path>] [--unity-version <text>]
|
||||||
|
[--not-restore-extension] [--load-all]
|
||||||
|
|
||||||
|
|
||||||
|
General Options:
|
||||||
|
-m, --mode <value> Specify working mode
|
||||||
|
<Value: export(default) | exportRaw | dump | info | live2d | splitObjects>
|
||||||
|
Export - Exports converted assets
|
||||||
|
ExportRaw - Exports raw data
|
||||||
|
Dump - Makes asset dumps
|
||||||
|
Info - Loads file(s), shows the number of available for export assets and exits
|
||||||
|
Live2D - Exports Live2D Cubism 3 models
|
||||||
|
SplitObjects - Exports split objects (fbx)
|
||||||
|
Example: "-m info"
|
||||||
|
|
||||||
|
-t, --asset-type <value(s)> Specify asset type(s) to export
|
||||||
|
<Value(s): tex2d, sprite, akPortrait, textAsset, monoBehaviour, font, shader,
|
||||||
|
movieTexture, audio, video, mesh | all(default)>
|
||||||
|
All - export all asset types, which are listed in the values
|
||||||
|
*To specify multiple asset types, write them separated by ',' or ';' without spaces
|
||||||
|
Examples: "-t sprite" or "-t tex2d,sprite,audio" or "-t tex2d;sprite;font"
|
||||||
|
|
||||||
|
-g, --group-option <value> Specify the way in which exported assets should be grouped
|
||||||
|
<Value: none | type | container(default) | containerFull | filename>
|
||||||
|
None - Do not group exported assets
|
||||||
|
Type - Group exported assets by type name
|
||||||
|
Container - Group exported assets by container path
|
||||||
|
ContainerFull - Group exported assets by full container path (e.g. with prefab name)
|
||||||
|
Filename - Group exported assets by source file name
|
||||||
|
Example: "-g container"
|
||||||
|
|
||||||
|
-o, --output <path> Specify path to the output folder
|
||||||
|
If path isn't specified, 'ASExport' folder will be created in the program's work folder
|
||||||
|
|
||||||
|
-h, --help Display help and exit
|
||||||
|
|
||||||
|
Logger Options:
|
||||||
|
--log-level <value> Specify the log level
|
||||||
|
<Value: verbose | debug | info(default) | warning | error>
|
||||||
|
Example: "--log-level warning"
|
||||||
|
|
||||||
|
--log-output <value> Specify the log output
|
||||||
|
<Value: console(default) | file | both>
|
||||||
|
Example: "--log-output both"
|
||||||
|
|
||||||
|
Convert Options:
|
||||||
|
--image-format <value> Specify the format for converting image assets
|
||||||
|
<Value: none | jpg | png(default) | bmp | tga | webp>
|
||||||
|
None - Do not convert images and export them as texture data (.tex)
|
||||||
|
Example: "--image-format jpg"
|
||||||
|
|
||||||
|
--audio-format <value> Specify the format for converting audio assets
|
||||||
|
<Value: none | wav(default)>
|
||||||
|
None - Do not convert audios and export them in their own format
|
||||||
|
Example: "--audio-format wav"
|
||||||
|
|
||||||
|
Live2D Options:
|
||||||
|
--l2d-motion-mode <value> Specify Live2D motion export mode
|
||||||
|
<Value: monoBehaviour(default) | animationClip>
|
||||||
|
MonoBehaviour - Try to export motions from MonoBehaviour Fade motions
|
||||||
|
If no Fade motions are found, the AnimationClip method will be used
|
||||||
|
AnimationClip - Try to export motions using AnimationClip assets
|
||||||
|
Example: "--l2d-motion-mode animationClip"
|
||||||
|
|
||||||
|
--l2d-force-bezier (Flag) If specified, Linear motion segments will be calculated as Bezier segments
|
||||||
|
(May help if the exported motions look jerky/not smooth enough)
|
||||||
|
|
||||||
|
FBX Options:
|
||||||
|
--fbx-scale-factor <value> Specify the FBX Scale Factor
|
||||||
|
<Value: float number from 0 to 100 (default=1)
|
||||||
|
Example: "--fbx-scale-factor 50"
|
||||||
|
|
||||||
|
--fbx-bone-size <value> Specify the FBX Bone Size
|
||||||
|
<Value: integer number from 0 to 100 (default=10)
|
||||||
|
Example: "--fbx-bone-size 10"
|
||||||
|
|
||||||
|
Filter Options:
|
||||||
|
--filter-by-name <text> Specify the name by which assets should be filtered
|
||||||
|
*To specify multiple names write them separated by ',' or ';' without spaces
|
||||||
|
Example: "--filter-by-name char" or "--filter-by-name char,bg"
|
||||||
|
|
||||||
|
--filter-by-container <text> Specify the container by which assets should be filtered
|
||||||
|
*To specify multiple containers write them separated by ',' or ';' without spaces
|
||||||
|
Example: "--filter-by-container arts" or "--filter-by-container arts,icons"
|
||||||
|
|
||||||
|
--filter-by-pathid <text> Specify the PathID by which assets should be filtered
|
||||||
|
*To specify multiple PathIDs write them separated by ',' or ';' without spaces
|
||||||
|
Example: "--filter-by-pathid 7238605633795851352,-2430306240205277265"
|
||||||
|
|
||||||
|
--filter-by-text <text> Specify the text by which assets should be filtered
|
||||||
|
Looks for assets that contain the specified text in their names or containers
|
||||||
|
*To specify multiple values write them separated by ',' or ';' without spaces
|
||||||
|
Example: "--filter-by-text portrait" or "--filter-by-text portrait,art"
|
||||||
|
|
||||||
|
|
||||||
|
Arknights Options:
|
||||||
|
--spritealpha-mode <value> Specify the mode in which you want to export sprites with alpha texture
|
||||||
|
<Value: none | internalOnly | searchExternal(default)>
|
||||||
|
None - Export sprites without alpha texture applied
|
||||||
|
InternalOnly - Export sprites with internal alpha texture applied (if exist)
|
||||||
|
SearchExternal - Export sprites with internal alpha texture applied,
|
||||||
|
and in case it doesn't exist, Studio will try to find an external alpha texture
|
||||||
|
Example: "--spritealpha-mode internalOnly"
|
||||||
|
|
||||||
|
--alphatex-resampler <value> Specify the alpha texture upscale algorithm for 2048x2048 sprites
|
||||||
|
<Value: nearest | bilinear | bicubic | mitchell(default) | spline | welch>
|
||||||
|
Mitchell - Mitchell Netravali algorithm. Yields good equilibrium between
|
||||||
|
sharpness and smoothness (produces less artifacts than bicubic in the current use case)
|
||||||
|
Spline - Similar to Mitchell Netravali but yielding smoother results
|
||||||
|
Welch - A high speed algorithm that delivers very sharpened results
|
||||||
|
Example: "--alphatex-resampler bicubic"
|
||||||
|
|
||||||
|
--shadow-gamma <value> Specify the gamma correction of semi-transparent shadow for 2048x2048 sprites
|
||||||
|
<Value: integer number from -5 to 5 (default=2)>
|
||||||
|
<0 - Make the shadow darker
|
||||||
|
0 - Do not change the brightness of the shadow
|
||||||
|
>0 - Make the shadow lighter
|
||||||
|
Example: "--shadow-gamma 0"
|
||||||
|
|
||||||
|
--original-avg-names (Flag) If specified, names of avg character sprites will not be restored
|
||||||
|
|
||||||
|
--add-aliases (Flag) If specified, aliases will be added to avg character sprite names (if exist)
|
||||||
|
|
||||||
|
Advanced Options:
|
||||||
|
--export-asset-list <value> Specify the format in which you want to export asset list
|
||||||
|
<Value: none(default) | xml>
|
||||||
|
None - Do not export asset list
|
||||||
|
Example: "--export-asset-list xml"
|
||||||
|
|
||||||
|
--assembly-folder <path> Specify the path to the assembly folder
|
||||||
|
|
||||||
|
--unity-version <text> Specify Unity version
|
||||||
|
Example: "--unity-version 2017.4.39f1"
|
||||||
|
|
||||||
|
--not-restore-extension (Flag) If specified, Studio will not try to use/restore original TextAsset
|
||||||
|
extension name, and will just export all TextAssets with the ".txt" extension
|
||||||
|
|
||||||
|
--load-all (Flag) If specified, Studio will load assets of all types
|
||||||
|
(Only for Dump, Info and ExportRaw modes)
|
||||||
|
```
|
||||||
721
AssetStudioCLI/Studio.cs
Normal file
721
AssetStudioCLI/Studio.cs
Normal file
@@ -0,0 +1,721 @@
|
|||||||
|
using AssetStudio;
|
||||||
|
using AssetStudioCLI.Options;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
using static AssetStudioCLI.Exporter;
|
||||||
|
using static CubismLive2DExtractor.Live2DExtractor;
|
||||||
|
using Ansi = AssetStudio.ColorConsole;
|
||||||
|
|
||||||
|
namespace AssetStudioCLI
|
||||||
|
{
|
||||||
|
internal static class Studio
|
||||||
|
{
|
||||||
|
public static AssetsManager assetsManager = new AssetsManager();
|
||||||
|
public static List<AssetItem> exportableAssetsList = new List<AssetItem>();
|
||||||
|
public static List<AssetItem> loadedAssetsList = new List<AssetItem>();
|
||||||
|
public static List<BaseNode> gameObjectTree = new List<BaseNode>();
|
||||||
|
public static AssemblyLoader assemblyLoader = new AssemblyLoader();
|
||||||
|
private static Dictionary<AssetStudio.Object, string> containers = new Dictionary<AssetStudio.Object, string>();
|
||||||
|
|
||||||
|
static Studio()
|
||||||
|
{
|
||||||
|
Progress.Default = new Progress<int>(ShowCurProgressValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ShowCurProgressValue(int value)
|
||||||
|
{
|
||||||
|
Console.Write($"[{value:000}%]\r");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool LoadAssets()
|
||||||
|
{
|
||||||
|
var isLoaded = false;
|
||||||
|
assetsManager.SpecifyUnityVersion = CLIOptions.o_unityVersion.Value;
|
||||||
|
if (!CLIOptions.f_loadAllAssets.Value)
|
||||||
|
{
|
||||||
|
assetsManager.SetAssetFilter(CLIOptions.o_exportAssetTypes.Value);
|
||||||
|
}
|
||||||
|
assetsManager.LoadFilesAndFolders(CLIOptions.inputPath);
|
||||||
|
if (assetsManager.assetsFileList.Count == 0)
|
||||||
|
{
|
||||||
|
Logger.Warning("No Unity file can be loaded.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
isLoaded = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isLoaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ParseAssets()
|
||||||
|
{
|
||||||
|
Logger.Info("Parse assets...");
|
||||||
|
|
||||||
|
var objectCount = assetsManager.assetsFileList.Sum(x => x.Objects.Count);
|
||||||
|
var objectAssetItemDic = new Dictionary<AssetStudio.Object, AssetItem>(objectCount);
|
||||||
|
|
||||||
|
Progress.Reset();
|
||||||
|
var i = 0;
|
||||||
|
foreach (var assetsFile in assetsManager.assetsFileList)
|
||||||
|
{
|
||||||
|
var preloadTable = Array.Empty<PPtr<AssetStudio.Object>>();
|
||||||
|
foreach (var asset in assetsFile.Objects)
|
||||||
|
{
|
||||||
|
var assetItem = new AssetItem(asset);
|
||||||
|
objectAssetItemDic.Add(asset, assetItem);
|
||||||
|
assetItem.UniqueID = "_#" + i;
|
||||||
|
var isExportable = false;
|
||||||
|
switch (asset)
|
||||||
|
{
|
||||||
|
case PreloadData m_PreloadData:
|
||||||
|
preloadTable = m_PreloadData.m_Assets;
|
||||||
|
break;
|
||||||
|
case AssetBundle m_AssetBundle:
|
||||||
|
var isStreamedSceneAssetBundle = m_AssetBundle.m_IsStreamedSceneAssetBundle;
|
||||||
|
if (!isStreamedSceneAssetBundle)
|
||||||
|
{
|
||||||
|
preloadTable = m_AssetBundle.m_PreloadTable;
|
||||||
|
}
|
||||||
|
assetItem.Text = string.IsNullOrEmpty(m_AssetBundle.m_AssetBundleName) ? m_AssetBundle.m_Name : m_AssetBundle.m_AssetBundleName;
|
||||||
|
|
||||||
|
foreach (var m_Container in m_AssetBundle.m_Container)
|
||||||
|
{
|
||||||
|
var preloadIndex = m_Container.Value.preloadIndex;
|
||||||
|
var preloadSize = isStreamedSceneAssetBundle ? preloadTable.Length : m_Container.Value.preloadSize;
|
||||||
|
var preloadEnd = preloadIndex + preloadSize;
|
||||||
|
for (var k = preloadIndex; k < preloadEnd; k++)
|
||||||
|
{
|
||||||
|
var pptr = preloadTable[k];
|
||||||
|
if (pptr.TryGet(out var obj))
|
||||||
|
{
|
||||||
|
containers[obj] = m_Container.Key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ResourceManager m_ResourceManager:
|
||||||
|
foreach (var m_Container in m_ResourceManager.m_Container)
|
||||||
|
{
|
||||||
|
if (m_Container.Value.TryGet(out var obj))
|
||||||
|
{
|
||||||
|
containers[obj] = m_Container.Key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Texture2D m_Texture2D:
|
||||||
|
if (!string.IsNullOrEmpty(m_Texture2D.m_StreamData?.path))
|
||||||
|
assetItem.FullSize = asset.byteSize + m_Texture2D.m_StreamData.size;
|
||||||
|
assetItem.Text = m_Texture2D.m_Name;
|
||||||
|
break;
|
||||||
|
case AudioClip m_AudioClip:
|
||||||
|
if (!string.IsNullOrEmpty(m_AudioClip.m_Source))
|
||||||
|
assetItem.FullSize = asset.byteSize + m_AudioClip.m_Size;
|
||||||
|
assetItem.Text = m_AudioClip.m_Name;
|
||||||
|
break;
|
||||||
|
case VideoClip m_VideoClip:
|
||||||
|
if (!string.IsNullOrEmpty(m_VideoClip.m_OriginalPath))
|
||||||
|
assetItem.FullSize = asset.byteSize + m_VideoClip.m_ExternalResources.m_Size;
|
||||||
|
assetItem.Text = m_VideoClip.m_Name;
|
||||||
|
break;
|
||||||
|
case Shader m_Shader:
|
||||||
|
assetItem.Text = m_Shader.m_ParsedForm?.m_Name ?? m_Shader.m_Name;
|
||||||
|
break;
|
||||||
|
case MonoBehaviour m_MonoBehaviour:
|
||||||
|
if (m_MonoBehaviour.m_Name == "" && m_MonoBehaviour.m_Script.TryGet(out var m_Script))
|
||||||
|
{
|
||||||
|
assetItem.Text = m_Script.m_ClassName;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
assetItem.Text = m_MonoBehaviour.m_Name;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case GameObject m_GameObject:
|
||||||
|
assetItem.Text = m_GameObject.m_Name;
|
||||||
|
break;
|
||||||
|
case Animator m_Animator:
|
||||||
|
if (m_Animator.m_GameObject.TryGet(out var gameObject))
|
||||||
|
{
|
||||||
|
assetItem.Text = gameObject.m_Name;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case NamedObject m_NamedObject:
|
||||||
|
assetItem.Text = m_NamedObject.m_Name;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(assetItem.Text))
|
||||||
|
{
|
||||||
|
assetItem.Text = assetItem.TypeString + assetItem.UniqueID;
|
||||||
|
}
|
||||||
|
|
||||||
|
loadedAssetsList.Add(assetItem);
|
||||||
|
isExportable = CLIOptions.o_exportAssetTypes.Value.Contains(asset.type);
|
||||||
|
if (isExportable || (CLIOptions.f_loadAllAssets.Value && CLIOptions.o_exportAssetTypes.Value == CLIOptions.o_exportAssetTypes.DefaultValue))
|
||||||
|
{
|
||||||
|
exportableAssetsList.Add(assetItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
Progress.Report(++i, objectCount);
|
||||||
|
}
|
||||||
|
foreach (var asset in loadedAssetsList)
|
||||||
|
{
|
||||||
|
if (containers.TryGetValue(asset.Asset, out var container))
|
||||||
|
{
|
||||||
|
asset.Container = container;
|
||||||
|
|
||||||
|
if (asset.Type == ClassIDType.MonoBehaviour && container.Contains("/arts/charportraits/portraits"))
|
||||||
|
{
|
||||||
|
var portraitsList = Arknights.AkSpriteHelper.GeneratePortraits(asset);
|
||||||
|
foreach (var portrait in portraitsList)
|
||||||
|
{
|
||||||
|
exportableAssetsList.Add(new AssetItem(portrait));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (CLIOptions.o_workMode.Value != WorkMode.ExportLive2D)
|
||||||
|
{
|
||||||
|
containers.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CLIOptions.o_workMode.Value == WorkMode.SplitObjects)
|
||||||
|
{
|
||||||
|
BuildTreeStructure(objectAssetItemDic);
|
||||||
|
}
|
||||||
|
var log = $"Finished loading {assetsManager.assetsFileList.Count} files with {exportableAssetsList.Count} exportable assets";
|
||||||
|
var unityVer = assetsManager.assetsFileList[0].version;
|
||||||
|
long m_ObjectsCount;
|
||||||
|
if (unityVer[0] > 2020)
|
||||||
|
{
|
||||||
|
m_ObjectsCount = assetsManager.assetsFileList.Sum(x => x.m_Objects.LongCount(y =>
|
||||||
|
y.classID != (int)ClassIDType.Shader
|
||||||
|
&& CLIOptions.o_exportAssetTypes.Value.Any(k => (int)k == y.classID))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_ObjectsCount = assetsManager.assetsFileList.Sum(x => x.m_Objects.LongCount(y => CLIOptions.o_exportAssetTypes.Value.Any(k => (int)k == y.classID)));
|
||||||
|
}
|
||||||
|
var objectsCount = assetsManager.assetsFileList.Sum(x => x.Objects.LongCount(y => CLIOptions.o_exportAssetTypes.Value.Any(k => k == y.type)));
|
||||||
|
if (m_ObjectsCount != objectsCount)
|
||||||
|
{
|
||||||
|
log += $" and {m_ObjectsCount - objectsCount} assets failed to read";
|
||||||
|
}
|
||||||
|
Logger.Info(log);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void BuildTreeStructure(Dictionary<AssetStudio.Object, AssetItem> objectAssetItemDic)
|
||||||
|
{
|
||||||
|
Logger.Info("Building tree structure...");
|
||||||
|
|
||||||
|
var treeNodeDictionary = new Dictionary<GameObject, GameObjectNode>();
|
||||||
|
var assetsFileCount = assetsManager.assetsFileList.Count;
|
||||||
|
int j = 0;
|
||||||
|
Progress.Reset();
|
||||||
|
foreach (var assetsFile in assetsManager.assetsFileList)
|
||||||
|
{
|
||||||
|
var fileNode = new BaseNode(); //RootNode
|
||||||
|
|
||||||
|
foreach (var obj in assetsFile.Objects)
|
||||||
|
{
|
||||||
|
if (obj is GameObject m_GameObject)
|
||||||
|
{
|
||||||
|
if (!treeNodeDictionary.TryGetValue(m_GameObject, out var currentNode))
|
||||||
|
{
|
||||||
|
currentNode = new GameObjectNode(m_GameObject);
|
||||||
|
treeNodeDictionary.Add(m_GameObject, currentNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var pptr in m_GameObject.m_Components)
|
||||||
|
{
|
||||||
|
if (pptr.TryGet(out var m_Component))
|
||||||
|
{
|
||||||
|
objectAssetItemDic[m_Component].Node = currentNode;
|
||||||
|
if (m_Component is MeshFilter m_MeshFilter)
|
||||||
|
{
|
||||||
|
if (m_MeshFilter.m_Mesh.TryGet(out var m_Mesh))
|
||||||
|
{
|
||||||
|
objectAssetItemDic[m_Mesh].Node = currentNode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (m_Component is SkinnedMeshRenderer m_SkinnedMeshRenderer)
|
||||||
|
{
|
||||||
|
if (m_SkinnedMeshRenderer.m_Mesh.TryGet(out var m_Mesh))
|
||||||
|
{
|
||||||
|
objectAssetItemDic[m_Mesh].Node = currentNode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var parentNode = fileNode;
|
||||||
|
|
||||||
|
if (m_GameObject.m_Transform != null)
|
||||||
|
{
|
||||||
|
if (m_GameObject.m_Transform.m_Father.TryGet(out var m_Father))
|
||||||
|
{
|
||||||
|
if (m_Father.m_GameObject.TryGet(out var parentGameObject))
|
||||||
|
{
|
||||||
|
if (!treeNodeDictionary.TryGetValue(parentGameObject, out var parentGameObjectNode))
|
||||||
|
{
|
||||||
|
parentGameObjectNode = new GameObjectNode(parentGameObject);
|
||||||
|
treeNodeDictionary.Add(parentGameObject, parentGameObjectNode);
|
||||||
|
}
|
||||||
|
parentNode = parentGameObjectNode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
parentNode.nodes.Add(currentNode);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fileNode.nodes.Count > 0)
|
||||||
|
{
|
||||||
|
gameObjectTree.Add(fileNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
Progress.Report(++j, assetsFileCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
treeNodeDictionary.Clear();
|
||||||
|
objectAssetItemDic.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ShowExportableAssetsInfo()
|
||||||
|
{
|
||||||
|
var exportableAssetsCountDict = new Dictionary<ClassIDType, int>();
|
||||||
|
string info = "";
|
||||||
|
if (exportableAssetsList.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var asset in exportableAssetsList)
|
||||||
|
{
|
||||||
|
if (exportableAssetsCountDict.ContainsKey(asset.Type))
|
||||||
|
{
|
||||||
|
exportableAssetsCountDict[asset.Type] += 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
exportableAssetsCountDict.Add(asset.Type, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
info += "\n[Exportable Assets Count]\n";
|
||||||
|
foreach (var assetType in exportableAssetsCountDict.Keys)
|
||||||
|
{
|
||||||
|
info += $"# {assetType}: {exportableAssetsCountDict[assetType]}\n";
|
||||||
|
}
|
||||||
|
if (exportableAssetsCountDict.Count > 1)
|
||||||
|
{
|
||||||
|
info += $"#\n# Total: {exportableAssetsList.Count} assets";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
info += "No exportable assets found.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CLIOptions.o_logLevel.Value > LoggerEvent.Info)
|
||||||
|
{
|
||||||
|
Console.WriteLine(info);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.Info(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Filter()
|
||||||
|
{
|
||||||
|
switch (CLIOptions.o_workMode.Value)
|
||||||
|
{
|
||||||
|
case WorkMode.ExportLive2D:
|
||||||
|
case WorkMode.SplitObjects:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
FilterAssets();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void FilterAssets()
|
||||||
|
{
|
||||||
|
var assetsCount = exportableAssetsList.Count;
|
||||||
|
var filteredAssets = new List<AssetItem>();
|
||||||
|
|
||||||
|
switch(CLIOptions.filterBy)
|
||||||
|
{
|
||||||
|
case FilterBy.Name:
|
||||||
|
filteredAssets = exportableAssetsList.FindAll(x => CLIOptions.o_filterByName.Value.Any(y => x.Text.IndexOf(y, StringComparison.OrdinalIgnoreCase) >= 0));
|
||||||
|
Logger.Info(
|
||||||
|
$"Found [{filteredAssets.Count}/{assetsCount}] asset(s) " +
|
||||||
|
$"that contain {$"\"{string.Join("\", \"", CLIOptions.o_filterByName.Value)}\"".Color(Ansi.BrightYellow)} in their Names."
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case FilterBy.Container:
|
||||||
|
filteredAssets = exportableAssetsList.FindAll(x => CLIOptions.o_filterByContainer.Value.Any(y => x.Container.IndexOf(y, StringComparison.OrdinalIgnoreCase) >= 0));
|
||||||
|
Logger.Info(
|
||||||
|
$"Found [{filteredAssets.Count}/{assetsCount}] asset(s) " +
|
||||||
|
$"that contain {$"\"{string.Join("\", \"", CLIOptions.o_filterByContainer.Value)}\"".Color(Ansi.BrightYellow)} in their Containers."
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case FilterBy.PathID:
|
||||||
|
filteredAssets = exportableAssetsList.FindAll(x => CLIOptions.o_filterByPathID.Value.Any(y => x.m_PathID.ToString().IndexOf(y, StringComparison.OrdinalIgnoreCase) >= 0));
|
||||||
|
Logger.Info(
|
||||||
|
$"Found [{filteredAssets.Count}/{assetsCount}] asset(s) " +
|
||||||
|
$"that contain {$"\"{string.Join("\", \"", CLIOptions.o_filterByPathID.Value)}\"".Color(Ansi.BrightYellow)} in their PathIDs."
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case FilterBy.NameOrContainer:
|
||||||
|
filteredAssets = exportableAssetsList.FindAll(x =>
|
||||||
|
CLIOptions.o_filterByText.Value.Any(y => x.Text.IndexOf(y, StringComparison.OrdinalIgnoreCase) >= 0) ||
|
||||||
|
CLIOptions.o_filterByText.Value.Any(y => x.Container.IndexOf(y, StringComparison.OrdinalIgnoreCase) >= 0)
|
||||||
|
);
|
||||||
|
Logger.Info(
|
||||||
|
$"Found [{filteredAssets.Count}/{assetsCount}] asset(s) " +
|
||||||
|
$"that contain {$"\"{string.Join("\", \"", CLIOptions.o_filterByText.Value)}\"".Color(Ansi.BrightYellow)} in their Names or Contaniers."
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case FilterBy.NameAndContainer:
|
||||||
|
filteredAssets = exportableAssetsList.FindAll(x =>
|
||||||
|
CLIOptions.o_filterByName.Value.Any(y => x.Text.IndexOf(y, StringComparison.OrdinalIgnoreCase) >= 0) &&
|
||||||
|
CLIOptions.o_filterByContainer.Value.Any(y => x.Container.IndexOf(y, StringComparison.OrdinalIgnoreCase) >= 0)
|
||||||
|
);
|
||||||
|
Logger.Info(
|
||||||
|
$"Found [{filteredAssets.Count}/{assetsCount}] asset(s) " +
|
||||||
|
$"that contain {$"\"{string.Join("\", \"", CLIOptions.o_filterByContainer.Value)}\"".Color(Ansi.BrightYellow)} in their Containers " +
|
||||||
|
$"and {$"\"{string.Join("\", \"", CLIOptions.o_filterByName.Value)}\"".Color(Ansi.BrightYellow)} in their Names."
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
exportableAssetsList.Clear();
|
||||||
|
exportableAssetsList = filteredAssets;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ExportAssets()
|
||||||
|
{
|
||||||
|
var savePath = CLIOptions.o_outputFolder.Value;
|
||||||
|
var toExportCount = exportableAssetsList.Count;
|
||||||
|
var exportedCount = 0;
|
||||||
|
|
||||||
|
var groupOption = CLIOptions.o_groupAssetsBy.Value;
|
||||||
|
foreach (var asset in exportableAssetsList)
|
||||||
|
{
|
||||||
|
string exportPath;
|
||||||
|
switch (groupOption)
|
||||||
|
{
|
||||||
|
case AssetGroupOption.TypeName:
|
||||||
|
exportPath = Path.Combine(savePath, asset.TypeString);
|
||||||
|
break;
|
||||||
|
case AssetGroupOption.ContainerPath:
|
||||||
|
case AssetGroupOption.ContainerPathFull:
|
||||||
|
if (!string.IsNullOrEmpty(asset.Container))
|
||||||
|
{
|
||||||
|
exportPath = Path.Combine(savePath, Path.GetDirectoryName(asset.Container));
|
||||||
|
if (groupOption == AssetGroupOption.ContainerPathFull)
|
||||||
|
{
|
||||||
|
exportPath = Path.Combine(exportPath, Path.GetFileNameWithoutExtension(asset.Container));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
exportPath = savePath;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case AssetGroupOption.SourceFileName:
|
||||||
|
if (string.IsNullOrEmpty(asset.SourceFile.originalPath))
|
||||||
|
{
|
||||||
|
exportPath = Path.Combine(savePath, asset.SourceFile.fileName + "_export");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
exportPath = Path.Combine(savePath, Path.GetFileName(asset.SourceFile.originalPath) + "_export", asset.SourceFile.fileName);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
exportPath = savePath;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
exportPath += Path.DirectorySeparatorChar;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (CLIOptions.o_workMode.Value)
|
||||||
|
{
|
||||||
|
case WorkMode.ExportRaw:
|
||||||
|
Logger.Debug($"{CLIOptions.o_workMode}: {asset.Type} : {asset.Container} : {asset.Text}");
|
||||||
|
if (ExportRawFile(asset, exportPath))
|
||||||
|
{
|
||||||
|
exportedCount++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case WorkMode.Dump:
|
||||||
|
Logger.Debug($"{CLIOptions.o_workMode}: {asset.Type} : {asset.Container} : {asset.Text}");
|
||||||
|
if (ExportDumpFile(asset, exportPath))
|
||||||
|
{
|
||||||
|
exportedCount++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case WorkMode.Export:
|
||||||
|
Logger.Debug($"{CLIOptions.o_workMode}: {asset.Type} : {asset.Container} : {asset.Text}");
|
||||||
|
if (ExportConvertFile(asset, exportPath))
|
||||||
|
{
|
||||||
|
exportedCount++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.Error($"{asset.SourceFile.originalPath}: [{$"{asset.Type}: {asset.Text}".Color(Ansi.BrightRed)}] : Export error\n{ex}");
|
||||||
|
}
|
||||||
|
Console.Write($"Exported [{exportedCount}/{toExportCount}]\r");
|
||||||
|
}
|
||||||
|
Console.WriteLine("");
|
||||||
|
|
||||||
|
if (exportedCount == 0)
|
||||||
|
{
|
||||||
|
Logger.Default.Log(LoggerEvent.Info, "Nothing exported.", ignoreLevel: true);
|
||||||
|
}
|
||||||
|
else if (toExportCount > exportedCount)
|
||||||
|
{
|
||||||
|
Logger.Default.Log(LoggerEvent.Info, $"Finished exporting {exportedCount} asset(s) to \"{CLIOptions.o_outputFolder.Value.Color(Ansi.BrightYellow)}\".", ignoreLevel: true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.Default.Log(LoggerEvent.Info, $"Finished exporting {exportedCount} asset(s) to \"{CLIOptions.o_outputFolder.Value.Color(Ansi.BrightGreen)}\".", ignoreLevel: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (toExportCount > exportedCount)
|
||||||
|
{
|
||||||
|
Logger.Default.Log(LoggerEvent.Info, $"{toExportCount - exportedCount} asset(s) skipped (not extractable or file(s) already exist).", ignoreLevel: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ExportAssetList()
|
||||||
|
{
|
||||||
|
var savePath = CLIOptions.o_outputFolder.Value;
|
||||||
|
|
||||||
|
switch (CLIOptions.o_exportAssetList.Value)
|
||||||
|
{
|
||||||
|
case ExportListType.XML:
|
||||||
|
var filename = Path.Combine(savePath, "assets.xml");
|
||||||
|
var doc = new XDocument(
|
||||||
|
new XElement("Assets",
|
||||||
|
new XAttribute("filename", filename),
|
||||||
|
new XAttribute("createdAt", DateTime.UtcNow.ToString("s")),
|
||||||
|
exportableAssetsList.Select(
|
||||||
|
asset => new XElement("Asset",
|
||||||
|
new XElement("Name", asset.Text),
|
||||||
|
new XElement("Container", asset.Container),
|
||||||
|
new XElement("Type", new XAttribute("id", (int)asset.Type), asset.TypeString),
|
||||||
|
new XElement("PathID", asset.m_PathID),
|
||||||
|
new XElement("Source", asset.SourceFile.fullName),
|
||||||
|
new XElement("Size", asset.FullSize)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
doc.Save(filename);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Logger.Info($"Finished exporting asset list with {exportableAssetsList.Count} items.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ExportSplitObjects()
|
||||||
|
{
|
||||||
|
var savePath = CLIOptions.o_outputFolder.Value;
|
||||||
|
var searchList = CLIOptions.o_filterByName.Value;
|
||||||
|
var isFiltered = CLIOptions.filterBy == FilterBy.Name;
|
||||||
|
|
||||||
|
var exportableObjects = new List<GameObjectNode>();
|
||||||
|
var exportedCount = 0;
|
||||||
|
var k = 0;
|
||||||
|
|
||||||
|
Logger.Info($"Searching for objects to export..");
|
||||||
|
Progress.Reset();
|
||||||
|
var count = gameObjectTree.Sum(x => x.nodes.Count);
|
||||||
|
foreach (var node in gameObjectTree)
|
||||||
|
{
|
||||||
|
foreach (GameObjectNode j in node.nodes)
|
||||||
|
{
|
||||||
|
if (isFiltered)
|
||||||
|
{
|
||||||
|
if (!searchList.Any(searchText => j.gameObject.m_Name.IndexOf(searchText, StringComparison.OrdinalIgnoreCase) >= 0))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
var gameObjects = new List<GameObject>();
|
||||||
|
CollectNode(j, gameObjects);
|
||||||
|
|
||||||
|
if (gameObjects.All(x => x.m_SkinnedMeshRenderer == null && x.m_MeshFilter == null))
|
||||||
|
{
|
||||||
|
Progress.Report(++k, count);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
exportableObjects.Add(j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gameObjectTree.Clear();
|
||||||
|
var exportableCount = exportableObjects.Count;
|
||||||
|
var log = $"Found {exportableCount} exportable object(s) ";
|
||||||
|
if (isFiltered)
|
||||||
|
{
|
||||||
|
log += $"that contain {$"\"{string.Join("\", \"", CLIOptions.o_filterByName.Value)}\"".Color(Ansi.BrightYellow)} in their Names";
|
||||||
|
}
|
||||||
|
Logger.Info(log);
|
||||||
|
if (exportableCount > 0)
|
||||||
|
{
|
||||||
|
Progress.Reset();
|
||||||
|
k = 0;
|
||||||
|
|
||||||
|
foreach (var gameObjectNode in exportableObjects)
|
||||||
|
{
|
||||||
|
var gameObject = gameObjectNode.gameObject;
|
||||||
|
var filename = FixFileName(gameObject.m_Name);
|
||||||
|
var targetPath = $"{savePath}{filename}{Path.DirectorySeparatorChar}";
|
||||||
|
//重名文件处理
|
||||||
|
for (int i = 1; ; i++)
|
||||||
|
{
|
||||||
|
if (Directory.Exists(targetPath))
|
||||||
|
{
|
||||||
|
targetPath = $"{savePath}{filename} ({i}){Path.DirectorySeparatorChar}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Directory.CreateDirectory(targetPath);
|
||||||
|
//导出FBX
|
||||||
|
Logger.Info($"Exporting {filename}.fbx");
|
||||||
|
Progress.Report(k, exportableCount);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ExportGameObject(gameObject, targetPath);
|
||||||
|
Logger.Debug($"{gameObject.type} \"{filename}\" saved to \"{targetPath}\"");
|
||||||
|
exportedCount++;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.Error($"Export GameObject:{gameObject.m_Name} error", ex);
|
||||||
|
}
|
||||||
|
k++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var status = exportedCount > 0
|
||||||
|
? $"Finished exporting [{exportedCount}/{exportableCount}] object(s) to \"{CLIOptions.o_outputFolder.Value.Color(Ansi.BrightCyan)}\""
|
||||||
|
: "Nothing exported";
|
||||||
|
Logger.Default.Log(LoggerEvent.Info, status, ignoreLevel: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void CollectNode(GameObjectNode node, List<GameObject> gameObjects)
|
||||||
|
{
|
||||||
|
gameObjects.Add(node.gameObject);
|
||||||
|
foreach (GameObjectNode i in node.nodes)
|
||||||
|
{
|
||||||
|
CollectNode(i, gameObjects);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ExportLive2D()
|
||||||
|
{
|
||||||
|
var baseDestPath = Path.Combine(CLIOptions.o_outputFolder.Value, "Live2DOutput");
|
||||||
|
var useFullContainerPath = false;
|
||||||
|
var motionMode = CLIOptions.o_l2dMotionMode.Value;
|
||||||
|
var forceBezier = CLIOptions.f_l2dForceBezier.Value;
|
||||||
|
|
||||||
|
Progress.Reset();
|
||||||
|
Logger.Info($"Searching for Live2D files...");
|
||||||
|
|
||||||
|
var cubismMocs = exportableAssetsList.Where(x =>
|
||||||
|
{
|
||||||
|
if (x.Type == ClassIDType.MonoBehaviour)
|
||||||
|
{
|
||||||
|
((MonoBehaviour)x.Asset).m_Script.TryGet(out var m_Script);
|
||||||
|
return m_Script?.m_ClassName == "CubismMoc";
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}).Select(x => x.Asset).ToArray();
|
||||||
|
|
||||||
|
if (cubismMocs.Length == 0)
|
||||||
|
{
|
||||||
|
Logger.Default.Log(LoggerEvent.Info, "Live2D Cubism models were not found.", ignoreLevel: true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (cubismMocs.Length > 1)
|
||||||
|
{
|
||||||
|
var basePathSet = cubismMocs.Select(x =>
|
||||||
|
{
|
||||||
|
var pathLen = containers.TryGetValue(x, out var itemContainer) ? itemContainer.LastIndexOf("/") : 0;
|
||||||
|
pathLen = pathLen < 0 ? containers[x].Length : pathLen;
|
||||||
|
return itemContainer?.Substring(0, pathLen);
|
||||||
|
}).ToHashSet();
|
||||||
|
|
||||||
|
if (basePathSet.All(x => x == null))
|
||||||
|
{
|
||||||
|
Logger.Error($"Live2D Cubism export error: Cannot find any model related files.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (basePathSet.Count != cubismMocs.Length)
|
||||||
|
{
|
||||||
|
useFullContainerPath = true;
|
||||||
|
Logger.Debug($"useFullContainerPath: {useFullContainerPath}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var basePathList = cubismMocs.Select(x =>
|
||||||
|
{
|
||||||
|
containers.TryGetValue(x, out var container);
|
||||||
|
container = useFullContainerPath
|
||||||
|
? container
|
||||||
|
: container?.Substring(0, container.LastIndexOf("/"));
|
||||||
|
return container;
|
||||||
|
}).Where(x => x != null).ToList();
|
||||||
|
|
||||||
|
var lookup = containers.ToLookup(
|
||||||
|
x => basePathList.Find(b => x.Value.Contains(b) && x.Value.Split('/').Any(y => y == b.Substring(b.LastIndexOf("/") + 1))),
|
||||||
|
x => x.Key
|
||||||
|
);
|
||||||
|
|
||||||
|
var totalModelCount = lookup.LongCount(x => x.Key != null);
|
||||||
|
Logger.Info($"Found {totalModelCount} model(s).");
|
||||||
|
var modelCounter = 0;
|
||||||
|
foreach (var assets in lookup)
|
||||||
|
{
|
||||||
|
var srcContainer = assets.Key;
|
||||||
|
if (srcContainer == null)
|
||||||
|
continue;
|
||||||
|
var container = srcContainer;
|
||||||
|
|
||||||
|
Logger.Info($"[{modelCounter + 1}/{totalModelCount}] Exporting Live2D: \"{srcContainer.Color(Ansi.BrightCyan)}\"");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var modelName = useFullContainerPath ? Path.GetFileNameWithoutExtension(container) : container.Substring(container.LastIndexOf('/') + 1);
|
||||||
|
container = Path.HasExtension(container) ? container.Replace(Path.GetExtension(container), "") : container;
|
||||||
|
var destPath = Path.Combine(baseDestPath, container) + Path.DirectorySeparatorChar;
|
||||||
|
|
||||||
|
ExtractLive2D(assets, destPath, modelName, assemblyLoader, motionMode, forceBezier);
|
||||||
|
modelCounter++;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.Error($"Live2D model export error: \"{srcContainer}\"", ex);
|
||||||
|
}
|
||||||
|
Progress.Report(modelCounter, (int)totalModelCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
var status = modelCounter > 0 ?
|
||||||
|
$"Finished exporting [{modelCounter}/{totalModelCount}] Live2D model(s) to \"{CLIOptions.o_outputFolder.Value.Color(Ansi.BrightCyan)}\"" :
|
||||||
|
"Nothing exported.";
|
||||||
|
Logger.Default.Log(LoggerEvent.Info, status, ignoreLevel: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
using namespace System;
|
|
||||||
using namespace System::Reflection;
|
|
||||||
using namespace System::Runtime::CompilerServices;
|
|
||||||
using namespace System::Runtime::InteropServices;
|
|
||||||
using namespace System::Security::Permissions;
|
|
||||||
|
|
||||||
[assembly:AssemblyTitleAttribute(L"AssetStudioFBX")];
|
|
||||||
[assembly:AssemblyDescriptionAttribute(L"")];
|
|
||||||
[assembly:AssemblyConfigurationAttribute(L"")];
|
|
||||||
[assembly:AssemblyCompanyAttribute(L"")];
|
|
||||||
[assembly:AssemblyProductAttribute(L"AssetStudioFBX")];
|
|
||||||
[assembly:AssemblyCopyrightAttribute(L"Copyright © Perfare 2018-2020")];
|
|
||||||
[assembly:AssemblyTrademarkAttribute(L"")];
|
|
||||||
[assembly:AssemblyCultureAttribute(L"")];
|
|
||||||
|
|
||||||
[assembly:AssemblyVersionAttribute("1.0.*")];
|
|
||||||
|
|
||||||
[assembly:ComVisible(false)];
|
|
||||||
|
|
||||||
[assembly:CLSCompliantAttribute(true)];
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
#include "AssetStudioFBX.h"
|
|
||||||
|
|
||||||
namespace AssetStudio
|
|
||||||
{
|
|
||||||
char* Fbx::StringToUTF8(String^ s)
|
|
||||||
{
|
|
||||||
auto bytes = Text::Encoding::UTF8->GetBytes(s);
|
|
||||||
auto chars = new char[bytes->Length + 1];
|
|
||||||
pin_ptr<unsigned char> ptr = &bytes[0];
|
|
||||||
memcpy(chars, ptr, bytes->Length);
|
|
||||||
chars[bytes->Length] = '\0';
|
|
||||||
return chars;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Fbx::Init(FbxManager** pSdkManager, FbxScene** pScene)
|
|
||||||
{
|
|
||||||
*pSdkManager = FbxManager::Create();
|
|
||||||
if (!pSdkManager)
|
|
||||||
{
|
|
||||||
throw gcnew Exception(gcnew String("Unable to create the FBX SDK manager"));
|
|
||||||
}
|
|
||||||
|
|
||||||
FbxIOSettings* ios = FbxIOSettings::Create(*pSdkManager, IOSROOT);
|
|
||||||
(*pSdkManager)->SetIOSettings(ios);
|
|
||||||
*pScene = FbxScene::Create(*pSdkManager, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector3 Fbx::QuaternionToEuler(Quaternion q)
|
|
||||||
{
|
|
||||||
FbxAMatrix lMatrixRot;
|
|
||||||
lMatrixRot.SetQ(FbxQuaternion(q.X, q.Y, q.Z, q.W));
|
|
||||||
FbxVector4 lEuler = lMatrixRot.GetR();
|
|
||||||
return Vector3((float)lEuler[0], (float)lEuler[1], (float)lEuler[2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
Quaternion Fbx::EulerToQuaternion(Vector3 v)
|
|
||||||
{
|
|
||||||
FbxAMatrix lMatrixRot;
|
|
||||||
lMatrixRot.SetR(FbxVector4(v.X, v.Y, v.Z));
|
|
||||||
FbxQuaternion lQuaternion = lMatrixRot.GetQ();
|
|
||||||
return Quaternion((float)lQuaternion[0], (float)lQuaternion[1], (float)lQuaternion[2], (float)lQuaternion[3]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <fbxsdk.h>
|
|
||||||
|
|
||||||
#ifdef IOS_REF
|
|
||||||
#undef IOS_REF
|
|
||||||
#define IOS_REF (*(pSdkManager->GetIOSettings()))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace System;
|
|
||||||
using namespace System::Collections::Generic;
|
|
||||||
using namespace System::IO;
|
|
||||||
|
|
||||||
#define WITH_MARSHALLED_STRING(name,str,block)\
|
|
||||||
{ \
|
|
||||||
char* name; \
|
|
||||||
try \
|
|
||||||
{ \
|
|
||||||
name = StringToUTF8(str); \
|
|
||||||
block \
|
|
||||||
} \
|
|
||||||
finally \
|
|
||||||
{ \
|
|
||||||
delete name; \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
static char* FBXVersion[] =
|
|
||||||
{
|
|
||||||
FBX_2010_00_COMPATIBLE,
|
|
||||||
FBX_2011_00_COMPATIBLE,
|
|
||||||
FBX_2012_00_COMPATIBLE,
|
|
||||||
FBX_2013_00_COMPATIBLE,
|
|
||||||
FBX_2014_00_COMPATIBLE,
|
|
||||||
FBX_2016_00_COMPATIBLE
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace AssetStudio {
|
|
||||||
|
|
||||||
public ref class Fbx
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static Vector3 QuaternionToEuler(Quaternion q);
|
|
||||||
static Quaternion EulerToQuaternion(Vector3 v);
|
|
||||||
static char* StringToUTF8(String^ s);
|
|
||||||
static void Init(FbxManager** pSdkManager, FbxScene** pScene);
|
|
||||||
|
|
||||||
ref class Exporter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void Export(String^ path, IImported^ imported, bool eulerFilter, float filterPrecision,
|
|
||||||
bool allNodes, bool skins, bool animation, bool blendShape, bool castToBone, float boneSize, float scaleFactor, int versionIndex, bool isAscii);
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool exportSkins;
|
|
||||||
float boneSize;
|
|
||||||
IImported^ imported;
|
|
||||||
HashSet<String^>^ framePaths;
|
|
||||||
Dictionary<ImportedFrame^, size_t>^ frameToNode;
|
|
||||||
List<ImportedFrame^>^ meshFrames;
|
|
||||||
|
|
||||||
char* cDest;
|
|
||||||
FbxManager* pSdkManager;
|
|
||||||
FbxScene* pScene;
|
|
||||||
FbxExporter* pExporter;
|
|
||||||
FbxArray<FbxSurfacePhong*>* pMaterials;
|
|
||||||
FbxArray<FbxFileTexture*>* pTextures;
|
|
||||||
FbxPose* pBindPose;
|
|
||||||
|
|
||||||
Exporter(String^ name, IImported^ imported, bool allNodes, bool skins, bool castToBone, float boneSize, float scaleFactor, int versionIndex, bool isAscii);
|
|
||||||
~Exporter();
|
|
||||||
|
|
||||||
void Exporter::LinkTexture(ImportedMaterialTexture^ texture, FbxFileTexture* pTexture, FbxProperty& prop);
|
|
||||||
void SetJointsNode(ImportedFrame^ frame, HashSet<String^>^ bonePaths, bool allBones);
|
|
||||||
HashSet<String^>^ SearchHierarchy();
|
|
||||||
void SearchHierarchy(ImportedFrame^ frame, HashSet<String^>^ exportFrames);
|
|
||||||
void SetJointsFromImportedMeshes(bool allBones);
|
|
||||||
void ExportFrame(FbxNode* pParentNode, ImportedFrame^ frame);
|
|
||||||
void ExportMesh(FbxNode* pFrameNode, ImportedMesh^ iMesh);
|
|
||||||
FbxFileTexture* ExportTexture(ImportedTexture^ matTex);
|
|
||||||
void ExportAnimations(bool eulerFilter, float filterValue);
|
|
||||||
void ExportKeyframedAnimation(ImportedKeyframedAnimation^ parser, FbxString& kTakeName, FbxAnimCurveFilterUnroll* eulerFilter, float filterPrecision);
|
|
||||||
void ExportMorphs();
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,141 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Debug|x64">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|x64">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<VCProjectVersion>16.0</VCProjectVersion>
|
|
||||||
<ProjectGuid>{B82DD1BA-4EEC-4F29-A686-03D7F0DF39B8}</ProjectGuid>
|
|
||||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
|
||||||
<Keyword>ManagedCProj</Keyword>
|
|
||||||
<RootNamespace>AssetStudioFBX</RootNamespace>
|
|
||||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
|
||||||
<CLRSupport>true</CLRSupport>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
|
||||||
<CLRSupport>true</CLRSupport>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
|
||||||
<CLRSupport>true</CLRSupport>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
|
||||||
<CLRSupport>true</CLRSupport>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="Shared">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup />
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<PreprocessorDefinitions>FBXSDK_SHARED;WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>C:\Program Files\Autodesk\FBX\FBX SDK\2020.0.1\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<AdditionalDependencies>libfbxsdk.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
<AdditionalLibraryDirectories>C:\Program Files\Autodesk\FBX\FBX SDK\2020.0.1\lib\vs2017\x86\release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<PreprocessorDefinitions>FBXSDK_SHARED;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>C:\Program Files\Autodesk\FBX\FBX SDK\2020.0.1\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<AdditionalDependencies>libfbxsdk.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
<AdditionalLibraryDirectories>C:\Program Files\Autodesk\FBX\FBX SDK\2020.0.1\lib\vs2017\x64\release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<PreprocessorDefinitions>FBXSDK_SHARED;WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>C:\Program Files\Autodesk\FBX\FBX SDK\2020.0.1\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<AdditionalDependencies>libfbxsdk.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
<AdditionalLibraryDirectories>C:\Program Files\Autodesk\FBX\FBX SDK\2020.0.1\lib\vs2017\x86\release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<PreprocessorDefinitions>FBXSDK_SHARED;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>C:\Program Files\Autodesk\FBX\FBX SDK\2020.0.1\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<AdditionalDependencies>libfbxsdk.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
<AdditionalLibraryDirectories>C:\Program Files\Autodesk\FBX\FBX SDK\2020.0.1\lib\vs2017\x64\release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="AssetStudioFBX.h" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="AssemblyInfo.cpp" />
|
|
||||||
<ClCompile Include="AssetStudioFBX.cpp" />
|
|
||||||
<ClCompile Include="AssetStudioFBXExporter.cpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="System" />
|
|
||||||
<Reference Include="System.Core" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\AssetStudio\AssetStudio.csproj">
|
|
||||||
<Project>{7662f8c2-7bfd-442e-a948-a43b4f7eb06e}</Project>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup>
|
|
||||||
<Filter Include="源文件">
|
|
||||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
|
||||||
<Extensions>cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="头文件">
|
|
||||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
|
||||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="资源文件">
|
|
||||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
|
||||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
|
||||||
</Filter>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="AssetStudioFBX.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="AssemblyInfo.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="AssetStudioFBX.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="AssetStudioFBXExporter.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,915 +0,0 @@
|
|||||||
#include "AssetStudioFBX.h"
|
|
||||||
|
|
||||||
namespace AssetStudio
|
|
||||||
{
|
|
||||||
void Fbx::Exporter::Export(String^ path, IImported^ imported, bool eulerFilter, float filterPrecision,
|
|
||||||
bool allNodes, bool skins, bool animation, bool blendShape, bool castToBone, float boneSize, float scaleFactor, int versionIndex, bool isAscii)
|
|
||||||
{
|
|
||||||
FileInfo^ file = gcnew FileInfo(path);
|
|
||||||
DirectoryInfo^ dir = file->Directory;
|
|
||||||
if (!dir->Exists)
|
|
||||||
{
|
|
||||||
dir->Create();
|
|
||||||
}
|
|
||||||
String^ currentDir = Directory::GetCurrentDirectory();
|
|
||||||
Directory::SetCurrentDirectory(dir->FullName);
|
|
||||||
auto name = Path::GetFileName(path);
|
|
||||||
Exporter^ exporter = gcnew Exporter(name, imported, allNodes, skins, castToBone, boneSize, scaleFactor, versionIndex, isAscii);
|
|
||||||
if (blendShape)
|
|
||||||
{
|
|
||||||
exporter->ExportMorphs();
|
|
||||||
}
|
|
||||||
if (animation)
|
|
||||||
{
|
|
||||||
exporter->ExportAnimations(eulerFilter, filterPrecision);
|
|
||||||
}
|
|
||||||
exporter->pExporter->Export(exporter->pScene);
|
|
||||||
delete exporter;
|
|
||||||
|
|
||||||
Directory::SetCurrentDirectory(currentDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
Fbx::Exporter::Exporter(String^ name, IImported^ imported, bool allNodes, bool skins, bool castToBone, float boneSize, float scaleFactor, int versionIndex, bool isAscii)
|
|
||||||
{
|
|
||||||
this->imported = imported;
|
|
||||||
exportSkins = skins;
|
|
||||||
this->boneSize = boneSize;
|
|
||||||
|
|
||||||
cDest = NULL;
|
|
||||||
pSdkManager = NULL;
|
|
||||||
pScene = NULL;
|
|
||||||
pExporter = NULL;
|
|
||||||
pMaterials = NULL;
|
|
||||||
pTextures = NULL;
|
|
||||||
|
|
||||||
pin_ptr<FbxManager*> pSdkManagerPin = &pSdkManager;
|
|
||||||
pin_ptr<FbxScene*> pScenePin = &pScene;
|
|
||||||
Init(pSdkManagerPin, pScenePin);
|
|
||||||
|
|
||||||
IOS_REF.SetBoolProp(EXP_FBX_MATERIAL, true);
|
|
||||||
IOS_REF.SetBoolProp(EXP_FBX_TEXTURE, true);
|
|
||||||
IOS_REF.SetBoolProp(EXP_FBX_EMBEDDED, false);
|
|
||||||
IOS_REF.SetBoolProp(EXP_FBX_SHAPE, true);
|
|
||||||
IOS_REF.SetBoolProp(EXP_FBX_GOBO, true);
|
|
||||||
IOS_REF.SetBoolProp(EXP_FBX_ANIMATION, true);
|
|
||||||
IOS_REF.SetBoolProp(EXP_FBX_GLOBAL_SETTINGS, true);
|
|
||||||
|
|
||||||
FbxGlobalSettings& globalSettings = pScene->GetGlobalSettings();
|
|
||||||
globalSettings.SetSystemUnit(FbxSystemUnit(scaleFactor));
|
|
||||||
|
|
||||||
if (imported->AnimationList->Count > 0)
|
|
||||||
{
|
|
||||||
auto ani = imported->AnimationList[0];
|
|
||||||
if (ani->SampleRate == 60.0f)
|
|
||||||
{
|
|
||||||
globalSettings.SetTimeMode(FbxTime::eFrames60);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cDest = StringToUTF8(name);
|
|
||||||
pExporter = FbxExporter::Create(pScene, "");
|
|
||||||
|
|
||||||
int pFileFormat = 0;
|
|
||||||
if (versionIndex == 0)
|
|
||||||
{
|
|
||||||
pFileFormat = 3;
|
|
||||||
if (isAscii)
|
|
||||||
{
|
|
||||||
pFileFormat = 4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pExporter->SetFileExportVersion(FBXVersion[versionIndex]);
|
|
||||||
if (isAscii)
|
|
||||||
{
|
|
||||||
pFileFormat = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pExporter->Initialize(cDest, pFileFormat, pSdkManager->GetIOSettings()))
|
|
||||||
{
|
|
||||||
throw gcnew Exception(gcnew String("Failed to initialize FbxExporter: ") + gcnew String(pExporter->GetStatus().GetErrorString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
framePaths = nullptr;
|
|
||||||
if (!allNodes)
|
|
||||||
{
|
|
||||||
framePaths = SearchHierarchy();
|
|
||||||
if (!framePaths)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pBindPose = FbxPose::Create(pScene, "BindPose");
|
|
||||||
pScene->AddPose(pBindPose);
|
|
||||||
|
|
||||||
frameToNode = gcnew Dictionary<ImportedFrame^, size_t>();
|
|
||||||
meshFrames = imported->MeshList != nullptr ? gcnew List<ImportedFrame^>() : nullptr;
|
|
||||||
ExportFrame(pScene->GetRootNode(), imported->RootFrame);
|
|
||||||
|
|
||||||
if (imported->MeshList != nullptr)
|
|
||||||
{
|
|
||||||
SetJointsFromImportedMeshes(castToBone);
|
|
||||||
|
|
||||||
pMaterials = new FbxArray<FbxSurfacePhong*>();
|
|
||||||
pTextures = new FbxArray<FbxFileTexture*>();
|
|
||||||
pMaterials->Reserve(imported->MaterialList->Count);
|
|
||||||
pTextures->Reserve(imported->TextureList->Count);
|
|
||||||
|
|
||||||
for (int i = 0; i < meshFrames->Count; i++)
|
|
||||||
{
|
|
||||||
auto meshFram = meshFrames[i];
|
|
||||||
FbxNode* meshNode = (FbxNode*)frameToNode[meshFram];
|
|
||||||
ImportedMesh^ mesh = ImportedHelpers::FindMesh(meshFram->Path, imported->MeshList);
|
|
||||||
ExportMesh(meshNode, mesh);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SetJointsNode(imported->RootFrame, nullptr, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Fbx::Exporter::~Exporter()
|
|
||||||
{
|
|
||||||
imported = nullptr;
|
|
||||||
if (framePaths != nullptr)
|
|
||||||
{
|
|
||||||
framePaths->Clear();
|
|
||||||
}
|
|
||||||
if (frameToNode != nullptr)
|
|
||||||
{
|
|
||||||
frameToNode->Clear();
|
|
||||||
}
|
|
||||||
if (meshFrames != nullptr)
|
|
||||||
{
|
|
||||||
meshFrames->Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pMaterials != NULL)
|
|
||||||
{
|
|
||||||
delete pMaterials;
|
|
||||||
}
|
|
||||||
if (pTextures != NULL)
|
|
||||||
{
|
|
||||||
delete pTextures;
|
|
||||||
}
|
|
||||||
if (pExporter != NULL)
|
|
||||||
{
|
|
||||||
pExporter->Destroy();
|
|
||||||
}
|
|
||||||
if (pScene != NULL)
|
|
||||||
{
|
|
||||||
pScene->Destroy();
|
|
||||||
}
|
|
||||||
if (pSdkManager != NULL)
|
|
||||||
{
|
|
||||||
pSdkManager->Destroy();
|
|
||||||
}
|
|
||||||
if (cDest != NULL)
|
|
||||||
{
|
|
||||||
delete cDest;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Fbx::Exporter::SetJointsNode(ImportedFrame^ frame, HashSet<String^>^ bonePaths, bool castToBone)
|
|
||||||
{
|
|
||||||
size_t pointer;
|
|
||||||
if (frameToNode->TryGetValue(frame, pointer))
|
|
||||||
{
|
|
||||||
auto pNode = (FbxNode*)pointer;
|
|
||||||
if (castToBone)
|
|
||||||
{
|
|
||||||
FbxSkeleton* pJoint = FbxSkeleton::Create(pScene, "");
|
|
||||||
pJoint->Size.Set(FbxDouble(boneSize));
|
|
||||||
pJoint->SetSkeletonType(FbxSkeleton::eLimbNode);
|
|
||||||
pNode->SetNodeAttribute(pJoint);
|
|
||||||
}
|
|
||||||
else if (bonePaths->Contains(frame->Path))
|
|
||||||
{
|
|
||||||
FbxSkeleton* pJoint = FbxSkeleton::Create(pScene, "");
|
|
||||||
pJoint->Size.Set(FbxDouble(boneSize));
|
|
||||||
pJoint->SetSkeletonType(FbxSkeleton::eLimbNode);
|
|
||||||
pNode->SetNodeAttribute(pJoint);
|
|
||||||
|
|
||||||
pJoint = FbxSkeleton::Create(pScene, "");
|
|
||||||
pJoint->Size.Set(FbxDouble(boneSize));
|
|
||||||
pJoint->SetSkeletonType(FbxSkeleton::eLimbNode);
|
|
||||||
pNode->GetParent()->SetNodeAttribute(pJoint);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FbxNull* pNull = FbxNull::Create(pScene, "");
|
|
||||||
if (pNode->GetChildCount() > 0)
|
|
||||||
{
|
|
||||||
pNull->Look.Set(FbxNull::eNone);
|
|
||||||
}
|
|
||||||
|
|
||||||
pNode->SetNodeAttribute(pNull);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int i = 0; i < frame->Count; i++)
|
|
||||||
{
|
|
||||||
SetJointsNode(frame[i], bonePaths, castToBone);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HashSet<String^>^ Fbx::Exporter::SearchHierarchy()
|
|
||||||
{
|
|
||||||
if (imported->MeshList == nullptr || imported->MeshList->Count == 0)
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
HashSet<String^>^ exportFrames = gcnew HashSet<String^>();
|
|
||||||
SearchHierarchy(imported->RootFrame, exportFrames);
|
|
||||||
return exportFrames;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Fbx::Exporter::SearchHierarchy(ImportedFrame^ frame, HashSet<String^>^ exportFrames)
|
|
||||||
{
|
|
||||||
ImportedMesh^ meshListSome = ImportedHelpers::FindMesh(frame->Path, imported->MeshList);
|
|
||||||
if (meshListSome != nullptr)
|
|
||||||
{
|
|
||||||
ImportedFrame^ parent = frame;
|
|
||||||
while (parent != nullptr)
|
|
||||||
{
|
|
||||||
exportFrames->Add(parent->Path);
|
|
||||||
parent = parent->Parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ImportedBone^>^ boneList = meshListSome->BoneList;
|
|
||||||
if (boneList != nullptr)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < boneList->Count; i++)
|
|
||||||
{
|
|
||||||
if (!exportFrames->Contains(boneList[i]->Path))
|
|
||||||
{
|
|
||||||
ImportedFrame^ boneParent = imported->RootFrame->FindFrameByPath(boneList[i]->Path);
|
|
||||||
while (boneParent != nullptr)
|
|
||||||
{
|
|
||||||
exportFrames->Add(boneParent->Path);
|
|
||||||
boneParent = boneParent->Parent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < frame->Count; i++)
|
|
||||||
{
|
|
||||||
SearchHierarchy(frame[i], exportFrames);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Fbx::Exporter::SetJointsFromImportedMeshes(bool castToBone)
|
|
||||||
{
|
|
||||||
if (!exportSkins)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
HashSet<String^>^ bonePaths = gcnew HashSet<String^>();
|
|
||||||
for (int i = 0; i < imported->MeshList->Count; i++)
|
|
||||||
{
|
|
||||||
ImportedMesh^ meshList = imported->MeshList[i];
|
|
||||||
List<ImportedBone^>^ boneList = meshList->BoneList;
|
|
||||||
if (boneList != nullptr)
|
|
||||||
{
|
|
||||||
for (int j = 0; j < boneList->Count; j++)
|
|
||||||
{
|
|
||||||
ImportedBone^ bone = boneList[j];
|
|
||||||
bonePaths->Add(bone->Path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SetJointsNode(imported->RootFrame, bonePaths, castToBone);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Fbx::Exporter::ExportFrame(FbxNode* pParentNode, ImportedFrame^ frame)
|
|
||||||
{
|
|
||||||
if (framePaths == nullptr || framePaths->Contains(frame->Path))
|
|
||||||
{
|
|
||||||
FbxNode* pFrameNode;
|
|
||||||
WITH_MARSHALLED_STRING
|
|
||||||
(
|
|
||||||
pName,
|
|
||||||
frame->Name,
|
|
||||||
pFrameNode = FbxNode::Create(pScene, pName);
|
|
||||||
);
|
|
||||||
|
|
||||||
pFrameNode->LclScaling.Set(FbxDouble3(frame->LocalScale.X, frame->LocalScale.Y, frame->LocalScale.Z));
|
|
||||||
pFrameNode->LclRotation.Set(FbxDouble3(frame->LocalRotation.X, frame->LocalRotation.Y, frame->LocalRotation.Z));
|
|
||||||
pFrameNode->LclTranslation.Set(FbxDouble3(frame->LocalPosition.X, frame->LocalPosition.Y, frame->LocalPosition.Z));
|
|
||||||
pFrameNode->SetPreferedAngle(pFrameNode->LclRotation.Get());
|
|
||||||
pParentNode->AddChild(pFrameNode);
|
|
||||||
pBindPose->Add(pFrameNode, pFrameNode->EvaluateGlobalTransform());
|
|
||||||
|
|
||||||
if (imported->MeshList != nullptr && ImportedHelpers::FindMesh(frame->Path, imported->MeshList) != nullptr)
|
|
||||||
{
|
|
||||||
meshFrames->Add(frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
frameToNode->Add(frame, (size_t)pFrameNode);
|
|
||||||
|
|
||||||
for (int i = 0; i < frame->Count; i++)
|
|
||||||
{
|
|
||||||
ExportFrame(pFrameNode, frame[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Fbx::Exporter::ExportMesh(FbxNode* pFrameNode, ImportedMesh^ iMesh)
|
|
||||||
{
|
|
||||||
List<ImportedBone^>^ boneList = iMesh->BoneList;
|
|
||||||
bool hasBones;
|
|
||||||
if (exportSkins && boneList != nullptr)
|
|
||||||
{
|
|
||||||
hasBones = boneList->Count > 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hasBones = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
FbxArray<FbxCluster*>* pClusterArray = nullptr;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (hasBones)
|
|
||||||
{
|
|
||||||
pClusterArray = new FbxArray<FbxCluster*>(boneList->Count);
|
|
||||||
|
|
||||||
for (int i = 0; i < boneList->Count; i++)
|
|
||||||
{
|
|
||||||
auto bone = boneList[i];
|
|
||||||
if (bone->Path != nullptr)
|
|
||||||
{
|
|
||||||
auto frame = imported->RootFrame->FindFrameByPath(bone->Path);
|
|
||||||
auto boneNode = (FbxNode*)frameToNode[frame];
|
|
||||||
FbxString lClusterName = boneNode->GetNameOnly() + FbxString("Cluster");
|
|
||||||
FbxCluster* pCluster = FbxCluster::Create(pScene, lClusterName.Buffer());
|
|
||||||
pCluster->SetLink(boneNode);
|
|
||||||
pCluster->SetLinkMode(FbxCluster::eTotalOne);
|
|
||||||
pClusterArray->Add(pCluster);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pClusterArray->Add(NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FbxMesh* pMesh = FbxMesh::Create(pScene, pFrameNode->GetName());
|
|
||||||
pFrameNode->SetNodeAttribute(pMesh);
|
|
||||||
|
|
||||||
int vertexCount = 0;
|
|
||||||
for (int i = 0; i < iMesh->SubmeshList->Count; i++)
|
|
||||||
{
|
|
||||||
vertexCount += iMesh->SubmeshList[i]->VertexList->Count;
|
|
||||||
}
|
|
||||||
|
|
||||||
pMesh->InitControlPoints(vertexCount);
|
|
||||||
FbxVector4* pControlPoints = pMesh->GetControlPoints();
|
|
||||||
|
|
||||||
FbxGeometryElementNormal* lGeometryElementNormal = NULL;
|
|
||||||
if (iMesh->hasNormal)
|
|
||||||
{
|
|
||||||
lGeometryElementNormal = pMesh->CreateElementNormal();
|
|
||||||
lGeometryElementNormal->SetMappingMode(FbxGeometryElement::eByControlPoint);
|
|
||||||
lGeometryElementNormal->SetReferenceMode(FbxGeometryElement::eDirect);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (iMesh->hasUV[0])
|
|
||||||
{
|
|
||||||
auto lGeometryElementUV = pMesh->CreateElementUV("UV0", FbxLayerElement::eTextureDiffuse);
|
|
||||||
lGeometryElementUV->SetMappingMode(FbxGeometryElement::eByControlPoint);
|
|
||||||
lGeometryElementUV->SetReferenceMode(FbxGeometryElement::eDirect);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (iMesh->hasUV[1])
|
|
||||||
{
|
|
||||||
auto lGeometryElementUV = pMesh->CreateElementUV("UV1", FbxLayerElement::eTextureNormalMap);
|
|
||||||
lGeometryElementUV->SetMappingMode(FbxGeometryElement::eByControlPoint);
|
|
||||||
lGeometryElementUV->SetReferenceMode(FbxGeometryElement::eDirect);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*for (int uv = 0; uv < 8; uv++)
|
|
||||||
{
|
|
||||||
if (iMesh->hasUV[uv])
|
|
||||||
{
|
|
||||||
auto lGeometryElementUV = pMesh->CreateElementUV(FbxString("UV") + FbxString(uv));
|
|
||||||
lGeometryElementUV->SetMappingMode(FbxGeometryElement::eByControlPoint);
|
|
||||||
lGeometryElementUV->SetReferenceMode(FbxGeometryElement::eDirect);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
FbxGeometryElementTangent* lGeometryElementTangent = NULL;
|
|
||||||
if (iMesh->hasTangent)
|
|
||||||
{
|
|
||||||
lGeometryElementTangent = pMesh->CreateElementTangent();
|
|
||||||
lGeometryElementTangent->SetMappingMode(FbxGeometryElement::eByControlPoint);
|
|
||||||
lGeometryElementTangent->SetReferenceMode(FbxGeometryElement::eDirect);
|
|
||||||
}
|
|
||||||
|
|
||||||
FbxGeometryElementVertexColor* lGeometryElementVertexColor = NULL;
|
|
||||||
if (iMesh->hasColor)
|
|
||||||
{
|
|
||||||
lGeometryElementVertexColor = pMesh->CreateElementVertexColor();
|
|
||||||
lGeometryElementVertexColor->SetMappingMode(FbxGeometryElement::eByControlPoint);
|
|
||||||
lGeometryElementVertexColor->SetReferenceMode(FbxGeometryElement::eDirect);
|
|
||||||
}
|
|
||||||
|
|
||||||
FbxGeometryElementMaterial* lGeometryElementMaterial = pMesh->CreateElementMaterial();
|
|
||||||
lGeometryElementMaterial->SetMappingMode(FbxGeometryElement::eByPolygon);
|
|
||||||
lGeometryElementMaterial->SetReferenceMode(FbxGeometryElement::eIndexToDirect);
|
|
||||||
|
|
||||||
int firstVertex = 0;
|
|
||||||
for (int i = 0; i < iMesh->SubmeshList->Count; i++)
|
|
||||||
{
|
|
||||||
ImportedSubmesh^ meshObj = iMesh->SubmeshList[i];
|
|
||||||
List<ImportedVertex^>^ vertexList = meshObj->VertexList;
|
|
||||||
List<ImportedFace^>^ faceList = meshObj->FaceList;
|
|
||||||
|
|
||||||
int materialIndex = 0;
|
|
||||||
ImportedMaterial^ mat = ImportedHelpers::FindMaterial(meshObj->Material, imported->MaterialList);
|
|
||||||
if (mat != nullptr)
|
|
||||||
{
|
|
||||||
char* pMatName = NULL;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
pMatName = StringToUTF8(mat->Name);
|
|
||||||
int foundMat = -1;
|
|
||||||
for (int j = 0; j < pMaterials->GetCount(); j++)
|
|
||||||
{
|
|
||||||
FbxSurfacePhong* pMatTemp = pMaterials->GetAt(j);
|
|
||||||
if (strcmp(pMatTemp->GetName(), pMatName) == 0)
|
|
||||||
{
|
|
||||||
foundMat = j;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FbxSurfacePhong* pMat;
|
|
||||||
if (foundMat >= 0)
|
|
||||||
{
|
|
||||||
pMat = pMaterials->GetAt(foundMat);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FbxString lShadingName = "Phong";
|
|
||||||
Color diffuse = mat->Diffuse;
|
|
||||||
Color ambient = mat->Ambient;
|
|
||||||
Color emissive = mat->Emissive;
|
|
||||||
Color specular = mat->Specular;
|
|
||||||
Color reflection = mat->Reflection;
|
|
||||||
pMat = FbxSurfacePhong::Create(pScene, pMatName);
|
|
||||||
pMat->Diffuse.Set(FbxDouble3(diffuse.R, diffuse.G, diffuse.B));
|
|
||||||
//pMat->DiffuseFactor.Set(FbxDouble(diffuse.A));
|
|
||||||
pMat->Ambient.Set(FbxDouble3(ambient.R, ambient.G, ambient.B));
|
|
||||||
//pMat->AmbientFactor.Set(FbxDouble(ambient.A));
|
|
||||||
pMat->Emissive.Set(FbxDouble3(emissive.R, emissive.G, emissive.B));
|
|
||||||
//pMat->EmissiveFactor.Set(FbxDouble(emissive.A));
|
|
||||||
pMat->Specular.Set(FbxDouble3(specular.R, specular.G, specular.B));
|
|
||||||
//pMat->SpecularFactor.Set(FbxDouble(specular.A));
|
|
||||||
pMat->Reflection.Set(FbxDouble3(reflection.R, reflection.G, reflection.B));
|
|
||||||
//pMat->ReflectionFactor.Set(FbxDouble(reflection.A));
|
|
||||||
pMat->Shininess.Set(FbxDouble(mat->Shininess));
|
|
||||||
pMat->TransparencyFactor.Set(FbxDouble(mat->Transparency));
|
|
||||||
pMat->ShadingModel.Set(lShadingName);
|
|
||||||
pMaterials->Add(pMat);
|
|
||||||
}
|
|
||||||
materialIndex = pFrameNode->AddMaterial(pMat);
|
|
||||||
|
|
||||||
bool hasTexture = false;
|
|
||||||
|
|
||||||
for each (ImportedMaterialTexture ^ texture in mat->Textures)
|
|
||||||
{
|
|
||||||
auto pTexture = ExportTexture(ImportedHelpers::FindTexture(texture->Name, imported->TextureList));
|
|
||||||
if (pTexture != NULL)
|
|
||||||
{
|
|
||||||
if (texture->Dest == 0)
|
|
||||||
{
|
|
||||||
LinkTexture(texture, pTexture, pMat->Diffuse);
|
|
||||||
hasTexture = true;
|
|
||||||
}
|
|
||||||
else if (texture->Dest == 1)
|
|
||||||
{
|
|
||||||
LinkTexture(texture, pTexture, pMat->NormalMap);
|
|
||||||
hasTexture = true;
|
|
||||||
}
|
|
||||||
else if (texture->Dest == 2)
|
|
||||||
{
|
|
||||||
LinkTexture(texture, pTexture, pMat->Specular);
|
|
||||||
hasTexture = true;
|
|
||||||
}
|
|
||||||
else if (texture->Dest == 3)
|
|
||||||
{
|
|
||||||
LinkTexture(texture, pTexture, pMat->Bump);
|
|
||||||
hasTexture = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasTexture)
|
|
||||||
{
|
|
||||||
pFrameNode->SetShadingMode(FbxNode::eTextureShading);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
delete pMatName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int j = 0; j < vertexList->Count; j++)
|
|
||||||
{
|
|
||||||
ImportedVertex^ iVertex = vertexList[j];
|
|
||||||
|
|
||||||
Vector3 vertex = iVertex->Vertex;
|
|
||||||
pControlPoints[j + firstVertex] = FbxVector4(vertex.X, vertex.Y, vertex.Z, 0);
|
|
||||||
|
|
||||||
if (iMesh->hasNormal)
|
|
||||||
{
|
|
||||||
Vector3 normal = iVertex->Normal;
|
|
||||||
lGeometryElementNormal->GetDirectArray().Add(FbxVector4(normal.X, normal.Y, normal.Z, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
//for (int uv = 0; uv < 8; uv++)
|
|
||||||
for (int uv = 0; uv < 2; uv++)
|
|
||||||
{
|
|
||||||
if (iMesh->hasUV[uv])
|
|
||||||
{
|
|
||||||
auto m_UV = iVertex->UV[uv];
|
|
||||||
auto lGeometryElementUV = pMesh->GetElementUV(uv);
|
|
||||||
lGeometryElementUV->GetDirectArray().Add(FbxVector2(m_UV[0], m_UV[1]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (iMesh->hasTangent)
|
|
||||||
{
|
|
||||||
Vector4 tangent = iVertex->Tangent;
|
|
||||||
lGeometryElementTangent->GetDirectArray().Add(FbxVector4(tangent.X, tangent.Y, tangent.Z, tangent.W));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (iMesh->hasColor)
|
|
||||||
{
|
|
||||||
auto color = iVertex->Color;
|
|
||||||
lGeometryElementVertexColor->GetDirectArray().Add(FbxColor(color.R, color.G, color.B, color.A));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasBones && iVertex->BoneIndices != nullptr)
|
|
||||||
{
|
|
||||||
auto boneIndices = iVertex->BoneIndices;
|
|
||||||
auto weights4 = iVertex->Weights;
|
|
||||||
for (int k = 0; k < 4; k++)
|
|
||||||
{
|
|
||||||
if (boneIndices[k] < boneList->Count && weights4[k] > 0)
|
|
||||||
{
|
|
||||||
FbxCluster* pCluster = pClusterArray->GetAt(boneIndices[k]);
|
|
||||||
if (pCluster)
|
|
||||||
{
|
|
||||||
pCluster->AddControlPointIndex(j + firstVertex, weights4[k]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int j = 0; j < faceList->Count; j++)
|
|
||||||
{
|
|
||||||
ImportedFace^ face = faceList[j];
|
|
||||||
pMesh->BeginPolygon(materialIndex);
|
|
||||||
pMesh->AddPolygon(face->VertexIndices[0] + firstVertex);
|
|
||||||
pMesh->AddPolygon(face->VertexIndices[1] + firstVertex);
|
|
||||||
pMesh->AddPolygon(face->VertexIndices[2] + firstVertex);
|
|
||||||
pMesh->EndPolygon();
|
|
||||||
}
|
|
||||||
|
|
||||||
firstVertex += vertexList->Count;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasBones)
|
|
||||||
{
|
|
||||||
FbxSkin* pSkin = FbxSkin::Create(pScene, "");
|
|
||||||
FbxAMatrix lMeshMatrix = pFrameNode->EvaluateGlobalTransform();
|
|
||||||
for (int j = 0; j < boneList->Count; j++)
|
|
||||||
{
|
|
||||||
FbxCluster* pCluster = pClusterArray->GetAt(j);
|
|
||||||
if (pCluster)
|
|
||||||
{
|
|
||||||
auto boneMatrix = boneList[j]->Matrix;
|
|
||||||
FbxAMatrix lBoneMatrix;
|
|
||||||
for (int m = 0; m < 4; m++)
|
|
||||||
{
|
|
||||||
for (int n = 0; n < 4; n++)
|
|
||||||
{
|
|
||||||
lBoneMatrix.mData[m][n] = boneMatrix[m, n];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pCluster->SetTransformMatrix(lMeshMatrix);
|
|
||||||
pCluster->SetTransformLinkMatrix(lMeshMatrix * lBoneMatrix.Inverse());
|
|
||||||
|
|
||||||
pSkin->AddCluster(pCluster);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pSkin->GetClusterCount() > 0)
|
|
||||||
{
|
|
||||||
pMesh->AddDeformer(pSkin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (pClusterArray != NULL)
|
|
||||||
{
|
|
||||||
delete pClusterArray;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FbxFileTexture* Fbx::Exporter::ExportTexture(ImportedTexture^ matTex)
|
|
||||||
{
|
|
||||||
FbxFileTexture* pTex = NULL;
|
|
||||||
|
|
||||||
if (matTex != nullptr)
|
|
||||||
{
|
|
||||||
String^ matTexName = matTex->Name;
|
|
||||||
char* pTexName = NULL;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
pTexName = StringToUTF8(matTexName);
|
|
||||||
int foundTex = -1;
|
|
||||||
for (int i = 0; i < pTextures->GetCount(); i++)
|
|
||||||
{
|
|
||||||
FbxFileTexture* pTexTemp = pTextures->GetAt(i);
|
|
||||||
if (strcmp(pTexTemp->GetName(), pTexName) == 0)
|
|
||||||
{
|
|
||||||
foundTex = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (foundTex >= 0)
|
|
||||||
{
|
|
||||||
pTex = pTextures->GetAt(foundTex);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pTex = FbxFileTexture::Create(pScene, pTexName);
|
|
||||||
pTex->SetFileName(pTexName);
|
|
||||||
pTex->SetTextureUse(FbxTexture::eStandard);
|
|
||||||
pTex->SetMappingType(FbxTexture::eUV);
|
|
||||||
pTex->SetMaterialUse(FbxFileTexture::eModelMaterial);
|
|
||||||
pTex->SetSwapUV(false);
|
|
||||||
pTex->SetTranslation(0.0, 0.0);
|
|
||||||
pTex->SetScale(1.0, 1.0);
|
|
||||||
pTex->SetRotation(0.0, 0.0);
|
|
||||||
pTextures->Add(pTex);
|
|
||||||
|
|
||||||
FileInfo^ file = gcnew FileInfo(matTex->Name);
|
|
||||||
BinaryWriter^ writer = gcnew BinaryWriter(file->Create());
|
|
||||||
writer->Write(matTex->Data);
|
|
||||||
writer->Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
delete pTexName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return pTex;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Fbx::Exporter::LinkTexture(ImportedMaterialTexture^ texture, FbxFileTexture* pTexture, FbxProperty& prop)
|
|
||||||
{
|
|
||||||
pTexture->SetTranslation(texture->Offset.X, texture->Offset.Y);
|
|
||||||
pTexture->SetScale(texture->Scale.X, texture->Scale.Y);
|
|
||||||
prop.ConnectSrcObject(pTexture);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Fbx::Exporter::ExportAnimations(bool eulerFilter, float filterPrecision)
|
|
||||||
{
|
|
||||||
auto importedAnimationList = imported->AnimationList;
|
|
||||||
if (importedAnimationList == nullptr)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FbxAnimCurveFilterUnroll* lFilter = eulerFilter ? new FbxAnimCurveFilterUnroll() : NULL;
|
|
||||||
|
|
||||||
for (int i = 0; i < importedAnimationList->Count; i++)
|
|
||||||
{
|
|
||||||
auto importedAnimation = importedAnimationList[i];
|
|
||||||
FbxString kTakeName;
|
|
||||||
if (importedAnimation->Name)
|
|
||||||
{
|
|
||||||
WITH_MARSHALLED_STRING
|
|
||||||
(
|
|
||||||
pClipName,
|
|
||||||
importedAnimation->Name,
|
|
||||||
kTakeName = FbxString(pClipName);
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
kTakeName = FbxString("Take") + FbxString(i);
|
|
||||||
}
|
|
||||||
ExportKeyframedAnimation(importedAnimation, kTakeName, lFilter, filterPrecision);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Fbx::Exporter::ExportKeyframedAnimation(ImportedKeyframedAnimation^ parser, FbxString& kTakeName, FbxAnimCurveFilterUnroll* eulerFilter, float filterPrecision)
|
|
||||||
{
|
|
||||||
List<ImportedAnimationKeyframedTrack^>^ pAnimationList = parser->TrackList;
|
|
||||||
|
|
||||||
char* lTakeName = kTakeName.Buffer();
|
|
||||||
|
|
||||||
FbxAnimStack* lAnimStack = FbxAnimStack::Create(pScene, lTakeName);
|
|
||||||
FbxAnimLayer* lAnimLayer = FbxAnimLayer::Create(pScene, "Base Layer");
|
|
||||||
lAnimStack->AddMember(lAnimLayer);
|
|
||||||
|
|
||||||
for (int j = 0; j < pAnimationList->Count; j++)
|
|
||||||
{
|
|
||||||
ImportedAnimationKeyframedTrack^ keyframeList = pAnimationList[j];
|
|
||||||
if (keyframeList->Path == nullptr)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
auto frame = imported->RootFrame->FindFrameByPath(keyframeList->Path);
|
|
||||||
if (frame != nullptr)
|
|
||||||
{
|
|
||||||
FbxNode* pNode = (FbxNode*)frameToNode[frame];
|
|
||||||
|
|
||||||
FbxAnimCurve* lCurveSX = pNode->LclScaling.GetCurve(lAnimLayer, FBXSDK_CURVENODE_COMPONENT_X, true);
|
|
||||||
FbxAnimCurve* lCurveSY = pNode->LclScaling.GetCurve(lAnimLayer, FBXSDK_CURVENODE_COMPONENT_Y, true);
|
|
||||||
FbxAnimCurve* lCurveSZ = pNode->LclScaling.GetCurve(lAnimLayer, FBXSDK_CURVENODE_COMPONENT_Z, true);
|
|
||||||
FbxAnimCurve* lCurveRX = pNode->LclRotation.GetCurve(lAnimLayer, FBXSDK_CURVENODE_COMPONENT_X, true);
|
|
||||||
FbxAnimCurve* lCurveRY = pNode->LclRotation.GetCurve(lAnimLayer, FBXSDK_CURVENODE_COMPONENT_Y, true);
|
|
||||||
FbxAnimCurve* lCurveRZ = pNode->LclRotation.GetCurve(lAnimLayer, FBXSDK_CURVENODE_COMPONENT_Z, true);
|
|
||||||
FbxAnimCurve* lCurveTX = pNode->LclTranslation.GetCurve(lAnimLayer, FBXSDK_CURVENODE_COMPONENT_X, true);
|
|
||||||
FbxAnimCurve* lCurveTY = pNode->LclTranslation.GetCurve(lAnimLayer, FBXSDK_CURVENODE_COMPONENT_Y, true);
|
|
||||||
FbxAnimCurve* lCurveTZ = pNode->LclTranslation.GetCurve(lAnimLayer, FBXSDK_CURVENODE_COMPONENT_Z, true);
|
|
||||||
|
|
||||||
lCurveSX->KeyModifyBegin();
|
|
||||||
lCurveSY->KeyModifyBegin();
|
|
||||||
lCurveSZ->KeyModifyBegin();
|
|
||||||
lCurveRX->KeyModifyBegin();
|
|
||||||
lCurveRY->KeyModifyBegin();
|
|
||||||
lCurveRZ->KeyModifyBegin();
|
|
||||||
lCurveTX->KeyModifyBegin();
|
|
||||||
lCurveTY->KeyModifyBegin();
|
|
||||||
lCurveTZ->KeyModifyBegin();
|
|
||||||
|
|
||||||
FbxTime lTime;
|
|
||||||
|
|
||||||
for each (auto Scaling in keyframeList->Scalings)
|
|
||||||
{
|
|
||||||
lTime.SetSecondDouble(Scaling->time);
|
|
||||||
|
|
||||||
lCurveSX->KeySet(lCurveSX->KeyAdd(lTime), lTime, Scaling->value.X);
|
|
||||||
lCurveSY->KeySet(lCurveSY->KeyAdd(lTime), lTime, Scaling->value.Y);
|
|
||||||
lCurveSZ->KeySet(lCurveSZ->KeyAdd(lTime), lTime, Scaling->value.Z);
|
|
||||||
}
|
|
||||||
for each (auto Rotation in keyframeList->Rotations)
|
|
||||||
{
|
|
||||||
lTime.SetSecondDouble(Rotation->time);
|
|
||||||
|
|
||||||
lCurveRX->KeySet(lCurveRX->KeyAdd(lTime), lTime, Rotation->value.X);
|
|
||||||
lCurveRY->KeySet(lCurveRY->KeyAdd(lTime), lTime, Rotation->value.Y);
|
|
||||||
lCurveRZ->KeySet(lCurveRZ->KeyAdd(lTime), lTime, Rotation->value.Z);
|
|
||||||
}
|
|
||||||
for each (auto Translation in keyframeList->Translations)
|
|
||||||
{
|
|
||||||
lTime.SetSecondDouble(Translation->time);
|
|
||||||
|
|
||||||
lCurveTX->KeySet(lCurveTX->KeyAdd(lTime), lTime, Translation->value.X);
|
|
||||||
lCurveTY->KeySet(lCurveTY->KeyAdd(lTime), lTime, Translation->value.Y);
|
|
||||||
lCurveTZ->KeySet(lCurveTZ->KeyAdd(lTime), lTime, Translation->value.Z);
|
|
||||||
}
|
|
||||||
|
|
||||||
lCurveSX->KeyModifyEnd();
|
|
||||||
lCurveSY->KeyModifyEnd();
|
|
||||||
lCurveSZ->KeyModifyEnd();
|
|
||||||
lCurveRX->KeyModifyEnd();
|
|
||||||
lCurveRY->KeyModifyEnd();
|
|
||||||
lCurveRZ->KeyModifyEnd();
|
|
||||||
lCurveTX->KeyModifyEnd();
|
|
||||||
lCurveTY->KeyModifyEnd();
|
|
||||||
lCurveTZ->KeyModifyEnd();
|
|
||||||
|
|
||||||
if (eulerFilter)
|
|
||||||
{
|
|
||||||
FbxAnimCurve* lCurve[3];
|
|
||||||
lCurve[0] = lCurveRX;
|
|
||||||
lCurve[1] = lCurveRY;
|
|
||||||
lCurve[2] = lCurveRZ;
|
|
||||||
eulerFilter->Reset();
|
|
||||||
eulerFilter->SetQualityTolerance(filterPrecision);
|
|
||||||
eulerFilter->Apply(lCurve, 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
//BlendShape
|
|
||||||
if (keyframeList->BlendShape != nullptr)
|
|
||||||
{
|
|
||||||
FbxString channelName;
|
|
||||||
WITH_MARSHALLED_STRING
|
|
||||||
(
|
|
||||||
pClipName,
|
|
||||||
keyframeList->BlendShape->ChannelName,
|
|
||||||
channelName = FbxString(pClipName);
|
|
||||||
);
|
|
||||||
|
|
||||||
auto lGeometry = (FbxGeometry*)pNode->GetNodeAttribute();
|
|
||||||
int lBlendShapeDeformerCount = lGeometry->GetDeformerCount(FbxDeformer::eBlendShape);
|
|
||||||
if (lBlendShapeDeformerCount > 0)
|
|
||||||
{
|
|
||||||
FbxBlendShape* lBlendShape = (FbxBlendShape*)lGeometry->GetDeformer(0, FbxDeformer::eBlendShape);
|
|
||||||
int lBlendShapeChannelCount = lBlendShape->GetBlendShapeChannelCount();
|
|
||||||
for (int lChannelIndex = 0; lChannelIndex < lBlendShapeChannelCount; ++lChannelIndex)
|
|
||||||
{
|
|
||||||
FbxBlendShapeChannel* lChannel = lBlendShape->GetBlendShapeChannel(lChannelIndex);
|
|
||||||
FbxString lChannelName = lChannel->GetNameOnly();
|
|
||||||
if (lChannelName == channelName)
|
|
||||||
{
|
|
||||||
FbxAnimCurve* lAnimCurve = lGeometry->GetShapeChannel(0, lChannelIndex, lAnimLayer, true);
|
|
||||||
lAnimCurve->KeyModifyBegin();
|
|
||||||
|
|
||||||
for each (auto keyframe in keyframeList->BlendShape->Keyframes)
|
|
||||||
{
|
|
||||||
lTime.SetSecondDouble(keyframe->time);
|
|
||||||
int lKeyIndex = lAnimCurve->KeyAdd(lTime);
|
|
||||||
lAnimCurve->KeySetValue(lKeyIndex, keyframe->value);
|
|
||||||
lAnimCurve->KeySetInterpolation(lKeyIndex, FbxAnimCurveDef::eInterpolationCubic);
|
|
||||||
}
|
|
||||||
|
|
||||||
lAnimCurve->KeyModifyEnd();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Fbx::Exporter::ExportMorphs()
|
|
||||||
{
|
|
||||||
if (imported->MeshList == nullptr)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for each (ImportedMorph ^ morph in imported->MorphList)
|
|
||||||
{
|
|
||||||
auto frame = imported->RootFrame->FindFrameByPath(morph->Path);
|
|
||||||
if (frame != nullptr)
|
|
||||||
{
|
|
||||||
FbxNode* pNode = (FbxNode*)frameToNode[frame];
|
|
||||||
FbxMesh* pMesh = pNode->GetMesh();
|
|
||||||
|
|
||||||
FbxBlendShape* lBlendShape = FbxBlendShape::Create(pScene, pMesh->GetNameOnly() + FbxString("BlendShape"));
|
|
||||||
pMesh->AddDeformer(lBlendShape);
|
|
||||||
|
|
||||||
for (int i = 0; i < morph->Channels->Count; i++)
|
|
||||||
{
|
|
||||||
auto channel = morph->Channels[i];
|
|
||||||
|
|
||||||
FbxBlendShapeChannel* lBlendShapeChannel;
|
|
||||||
WITH_MARSHALLED_STRING
|
|
||||||
(
|
|
||||||
pChannelName,
|
|
||||||
channel->Name,
|
|
||||||
lBlendShapeChannel = FbxBlendShapeChannel::Create(pScene, pChannelName);
|
|
||||||
);
|
|
||||||
lBlendShape->AddBlendShapeChannel(lBlendShapeChannel);
|
|
||||||
|
|
||||||
for each (ImportedMorphKeyframe ^ keyframe in channel->KeyframeList)
|
|
||||||
{
|
|
||||||
FbxShape* lShape = FbxShape::Create(pScene, FbxString(keyframe->Weight));
|
|
||||||
lBlendShapeChannel->AddTargetShape(lShape, keyframe->Weight);
|
|
||||||
|
|
||||||
auto vectorCount = pMesh->GetControlPointsCount();
|
|
||||||
FbxVector4* orilVector4 = pMesh->GetControlPoints();
|
|
||||||
lShape->InitControlPoints(vectorCount);
|
|
||||||
FbxVector4* lVector4 = lShape->GetControlPoints();
|
|
||||||
|
|
||||||
for (int j = 0; j < vectorCount; j++)
|
|
||||||
{
|
|
||||||
auto vertex = orilVector4[j];
|
|
||||||
lVector4[j] = FbxVector4(vertex);
|
|
||||||
}
|
|
||||||
for (int j = 0; j < keyframe->VertexList->Count; j++)
|
|
||||||
{
|
|
||||||
auto index = keyframe->VertexList[j]->Index;
|
|
||||||
auto vertex = keyframe->VertexList[j]->Vertex->Vertex;
|
|
||||||
lVector4[index] = FbxVector4(vertex.X, vertex.Y, vertex.Z, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
99
AssetStudioFBXNative/AssetStudioFBXNative.rc
Normal file
99
AssetStudioFBXNative/AssetStudioFBXNative.rc
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
// Microsoft Visual C++ generated resource script.
|
||||||
|
//
|
||||||
|
#include "resource.h"
|
||||||
|
|
||||||
|
#define APSTUDIO_READONLY_SYMBOLS
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Generated from the TEXTINCLUDE 2 resource.
|
||||||
|
//
|
||||||
|
#include "winres.h"
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#undef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Language neutral resources
|
||||||
|
|
||||||
|
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
|
||||||
|
LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
|
||||||
|
#pragma code_page(65001)
|
||||||
|
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// TEXTINCLUDE
|
||||||
|
//
|
||||||
|
|
||||||
|
1 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"resource.h\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
2 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"#include ""winres.h""\r\n"
|
||||||
|
"\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
3 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"\r\n"
|
||||||
|
"\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
#endif // APSTUDIO_INVOKED
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Version
|
||||||
|
//
|
||||||
|
|
||||||
|
VS_VERSION_INFO VERSIONINFO
|
||||||
|
FILEVERSION 1,0,0,1
|
||||||
|
PRODUCTVERSION 1,0,0,1
|
||||||
|
FILEFLAGSMASK 0x3fL
|
||||||
|
#ifdef _DEBUG
|
||||||
|
FILEFLAGS 0x1L
|
||||||
|
#else
|
||||||
|
FILEFLAGS 0x0L
|
||||||
|
#endif
|
||||||
|
FILEOS 0x40004L
|
||||||
|
FILETYPE 0x2L
|
||||||
|
FILESUBTYPE 0x0L
|
||||||
|
BEGIN
|
||||||
|
BLOCK "StringFileInfo"
|
||||||
|
BEGIN
|
||||||
|
BLOCK "000004b0"
|
||||||
|
BEGIN
|
||||||
|
VALUE "FileDescription", "AssetStudioFBXNative"
|
||||||
|
VALUE "FileVersion", "1.0.0.1"
|
||||||
|
VALUE "InternalName", "AssetStudioFBXNative.dll"
|
||||||
|
VALUE "LegalCopyright", "Copyright (C) Perfare 2018-2020; Copyright (C) hozuki 2020"
|
||||||
|
VALUE "OriginalFilename", "AssetStudioFBXNative.dll"
|
||||||
|
VALUE "ProductName", "AssetStudioFBXNative"
|
||||||
|
VALUE "ProductVersion", "1.0.0.1"
|
||||||
|
END
|
||||||
|
END
|
||||||
|
BLOCK "VarFileInfo"
|
||||||
|
BEGIN
|
||||||
|
VALUE "Translation", 0x0, 1200
|
||||||
|
END
|
||||||
|
END
|
||||||
|
|
||||||
|
#endif // Language neutral resources
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Generated from the TEXTINCLUDE 3 resource.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#endif // not APSTUDIO_INVOKED
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user