From 3370f93037627f1507e6c87fe98de8182287679d Mon Sep 17 00:00:00 2001 From: Perfare Date: Mon, 6 Dec 2021 17:37:59 +0800 Subject: [PATCH 1/8] Fixed bug --- AssetStudio/EndianBinaryReader.cs | 2 +- AssetStudioUtility/Texture2DConverter.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/AssetStudio/EndianBinaryReader.cs b/AssetStudio/EndianBinaryReader.cs index c7f8ad0..5056a66 100644 --- a/AssetStudio/EndianBinaryReader.cs +++ b/AssetStudio/EndianBinaryReader.cs @@ -109,7 +109,7 @@ namespace AssetStudio { var buff = ReadBytes(8); Array.Reverse(buff); - return BitConverter.ToUInt64(buff, 0); + return BitConverter.ToDouble(buff, 0); } return base.ReadDouble(); } diff --git a/AssetStudioUtility/Texture2DConverter.cs b/AssetStudioUtility/Texture2DConverter.cs index dfaf14d..2459817 100644 --- a/AssetStudioUtility/Texture2DConverter.cs +++ b/AssetStudioUtility/Texture2DConverter.cs @@ -203,7 +203,7 @@ namespace AssetStudio { if (platform == BuildTarget.XBOX360) { - for (var i = 0; i < image_data.Length / 2; i++) + for (var i = 0; i < reader.Size / 2; i++) { var b = image_data[i * 2]; image_data[i * 2] = image_data[i * 2 + 1]; From 3660b4ed673e684aab5a9d71958938334f1c7559 Mon Sep 17 00:00:00 2001 From: Perfare Date: Thu, 9 Dec 2021 17:13:21 +0800 Subject: [PATCH 2/8] Some improvements --- AssetStudio/Classes/Mesh.cs | 2 +- AssetStudio/EndianBinaryReader.cs | 74 +++++++++++++------------------ AssetStudio/EndianType.cs | 14 ++++++ AssetStudio/ObjectReader.cs | 2 +- AssetStudio/SerializedFile.cs | 2 +- AssetStudio/WebFile.cs | 2 +- 6 files changed, 50 insertions(+), 46 deletions(-) create mode 100644 AssetStudio/EndianType.cs diff --git a/AssetStudio/Classes/Mesh.cs b/AssetStudio/Classes/Mesh.cs index 0945f43..0a2369d 100644 --- a/AssetStudio/Classes/Mesh.cs +++ b/AssetStudio/Classes/Mesh.cs @@ -729,7 +729,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++) { diff --git a/AssetStudio/EndianBinaryReader.cs b/AssetStudio/EndianBinaryReader.cs index 5056a66..9beb801 100644 --- a/AssetStudio/EndianBinaryReader.cs +++ b/AssetStudio/EndianBinaryReader.cs @@ -1,23 +1,19 @@ using System; -using System.Collections.Generic; -using System.Text; +using System.Buffers.Binary; using System.IO; namespace AssetStudio { - public enum EndianType - { - LittleEndian, - BigEndian - } - public class EndianBinaryReader : BinaryReader { - public EndianType endian; + private readonly byte[] buffer; + + public EndianType Endian; public EndianBinaryReader(Stream stream, EndianType endian = EndianType.BigEndian) : base(stream) { - this.endian = endian; + Endian = endian; + buffer = new byte[8]; } public long Position @@ -28,88 +24,82 @@ namespace AssetStudio public override short ReadInt16() { - if (endian == EndianType.BigEndian) + if (Endian == EndianType.BigEndian) { - var buff = ReadBytes(2); - Array.Reverse(buff); - return BitConverter.ToInt16(buff, 0); + Read(buffer, 0, 2); + return BinaryPrimitives.ReadInt16BigEndian(buffer); } return base.ReadInt16(); } public override int ReadInt32() { - if (endian == EndianType.BigEndian) + if (Endian == EndianType.BigEndian) { - var buff = ReadBytes(4); - Array.Reverse(buff); - return BitConverter.ToInt32(buff, 0); + Read(buffer, 0, 4); + return BinaryPrimitives.ReadInt32BigEndian(buffer); } return base.ReadInt32(); } public override long ReadInt64() { - if (endian == EndianType.BigEndian) + if (Endian == EndianType.BigEndian) { - var buff = ReadBytes(8); - Array.Reverse(buff); - return BitConverter.ToInt64(buff, 0); + Read(buffer, 0, 8); + return BinaryPrimitives.ReadInt64BigEndian(buffer); } return base.ReadInt64(); } public override ushort ReadUInt16() { - if (endian == EndianType.BigEndian) + if (Endian == EndianType.BigEndian) { - var buff = ReadBytes(2); - Array.Reverse(buff); - return BitConverter.ToUInt16(buff, 0); + Read(buffer, 0, 2); + return BinaryPrimitives.ReadUInt16BigEndian(buffer); } return base.ReadUInt16(); } public override uint ReadUInt32() { - if (endian == EndianType.BigEndian) + if (Endian == EndianType.BigEndian) { - var buff = ReadBytes(4); - Array.Reverse(buff); - return BitConverter.ToUInt32(buff, 0); + Read(buffer, 0, 4); + return BinaryPrimitives.ReadUInt32BigEndian(buffer); } return base.ReadUInt32(); } public override ulong ReadUInt64() { - if (endian == EndianType.BigEndian) + if (Endian == EndianType.BigEndian) { - var buff = ReadBytes(8); - Array.Reverse(buff); - return BitConverter.ToUInt64(buff, 0); + Read(buffer, 0, 8); + return BinaryPrimitives.ReadUInt64BigEndian(buffer); } return base.ReadUInt64(); } public override float ReadSingle() { - if (endian == EndianType.BigEndian) + if (Endian == EndianType.BigEndian) { - var buff = ReadBytes(4); - Array.Reverse(buff); - return BitConverter.ToSingle(buff, 0); + Read(buffer, 0, 4); + Array.Reverse(buffer, 0, 4); + return BitConverter.ToSingle(buffer, 0); } return base.ReadSingle(); } public override double ReadDouble() { - if (endian == EndianType.BigEndian) + if (Endian == EndianType.BigEndian) { - var buff = ReadBytes(8); - Array.Reverse(buff); - return BitConverter.ToDouble(buff, 0); + Read(buffer, 0, 8); + Array.Reverse(buffer); + return BitConverter.ToDouble(buffer, 0); } return base.ReadDouble(); } diff --git a/AssetStudio/EndianType.cs b/AssetStudio/EndianType.cs new file mode 100644 index 0000000..e178263 --- /dev/null +++ b/AssetStudio/EndianType.cs @@ -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 + } +} diff --git a/AssetStudio/ObjectReader.cs b/AssetStudio/ObjectReader.cs index 47b33bc..deb253b 100644 --- a/AssetStudio/ObjectReader.cs +++ b/AssetStudio/ObjectReader.cs @@ -20,7 +20,7 @@ namespace AssetStudio public int[] version => assetsFile.version; 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; m_PathID = objectInfo.m_PathID; diff --git a/AssetStudio/SerializedFile.cs b/AssetStudio/SerializedFile.cs index d10210d..41f8d90 100644 --- a/AssetStudio/SerializedFile.cs +++ b/AssetStudio/SerializedFile.cs @@ -68,7 +68,7 @@ namespace AssetStudio // ReadMetadata if (m_FileEndianess == 0) { - reader.endian = EndianType.LittleEndian; + reader.Endian = EndianType.LittleEndian; } if (header.m_Version >= SerializedFileFormatVersion.kUnknown_7) { diff --git a/AssetStudio/WebFile.cs b/AssetStudio/WebFile.cs index face612..ca61f85 100644 --- a/AssetStudio/WebFile.cs +++ b/AssetStudio/WebFile.cs @@ -17,7 +17,7 @@ namespace AssetStudio public WebFile(EndianBinaryReader reader) { - reader.endian = EndianType.LittleEndian; + reader.Endian = EndianType.LittleEndian; var signature = reader.ReadStringToNull(); var headLength = reader.ReadInt32(); var dataList = new List(); From a94caa5e34c682d550cd2e0348a808b7b2896f8a Mon Sep 17 00:00:00 2001 From: Perfare Date: Thu, 9 Dec 2021 17:21:44 +0800 Subject: [PATCH 3/8] Update project --- .../AssetStudioFBXNative.vcxproj | 24 +++++++++---------- .../Texture2DDecoderNative.vcxproj | 8 +++---- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/AssetStudioFBXNative/AssetStudioFBXNative.vcxproj b/AssetStudioFBXNative/AssetStudioFBXNative.vcxproj index a1e99dc..b7c1902 100644 --- a/AssetStudioFBXNative/AssetStudioFBXNative.vcxproj +++ b/AssetStudioFBXNative/AssetStudioFBXNative.vcxproj @@ -29,26 +29,26 @@ DynamicLibrary true - v142 + v143 Unicode DynamicLibrary false - v142 + v143 true Unicode DynamicLibrary true - v142 + v143 Unicode DynamicLibrary false - v142 + v143 true Unicode @@ -100,14 +100,14 @@ true _AS_DLL;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - C:\Program Files\Autodesk\FBX\FBX SDK\2020.0.1\include;%(AdditionalIncludeDirectories) + C:\Program Files\Autodesk\FBX\FBX SDK\2020.2.1\include;%(AdditionalIncludeDirectories) MultiThreadedDebug Console true libfbxsdk-mt.lib;libxml2-mt.lib;zlib-mt.lib;wininet.lib;%(AdditionalDependencies) - C:\Program Files\Autodesk\FBX\FBX SDK\2020.0.1\lib\vs2017\x86\debug;%(AdditionalLibraryDirectories) + C:\Program Files\Autodesk\FBX\FBX SDK\2020.2.1\lib\vs2019\x86\debug;%(AdditionalLibraryDirectories) LIBCMT;%(IgnoreSpecificDefaultLibraries) @@ -119,7 +119,7 @@ true _AS_DLL;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true - C:\Program Files\Autodesk\FBX\FBX SDK\2020.0.1\include;%(AdditionalIncludeDirectories) + C:\Program Files\Autodesk\FBX\FBX SDK\2020.2.1\include;%(AdditionalIncludeDirectories) MultiThreaded @@ -128,7 +128,7 @@ true true libfbxsdk-mt.lib;libxml2-mt.lib;zlib-mt.lib;%(AdditionalDependencies) - C:\Program Files\Autodesk\FBX\FBX SDK\2020.0.1\lib\vs2017\x86\release;%(AdditionalLibraryDirectories) + C:\Program Files\Autodesk\FBX\FBX SDK\2020.2.1\lib\vs2019\x86\release;%(AdditionalLibraryDirectories) @@ -137,14 +137,14 @@ true _AS_DLL;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - C:\Program Files\Autodesk\FBX\FBX SDK\2020.0.1\include;%(AdditionalIncludeDirectories) + C:\Program Files\Autodesk\FBX\FBX SDK\2020.2.1\include;%(AdditionalIncludeDirectories) MultiThreadedDebug Console true libfbxsdk-mt.lib;libxml2-mt.lib;zlib-mt.lib;wininet.lib;%(AdditionalDependencies) - C:\Program Files\Autodesk\FBX\FBX SDK\2020.0.1\lib\vs2017\x64\debug;%(AdditionalLibraryDirectories) + C:\Program Files\Autodesk\FBX\FBX SDK\2020.2.1\lib\vs2019\x64\debug;%(AdditionalLibraryDirectories) LIBCMT;%(IgnoreSpecificDefaultLibraries) @@ -156,7 +156,7 @@ true _AS_DLL;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true - C:\Program Files\Autodesk\FBX\FBX SDK\2020.0.1\include;%(AdditionalIncludeDirectories) + C:\Program Files\Autodesk\FBX\FBX SDK\2020.2.1\include;%(AdditionalIncludeDirectories) MultiThreaded @@ -165,7 +165,7 @@ true true libfbxsdk-mt.lib;libxml2-mt.lib;zlib-mt.lib;%(AdditionalDependencies) - C:\Program Files\Autodesk\FBX\FBX SDK\2020.0.1\lib\vs2017\x64\release;%(AdditionalLibraryDirectories) + C:\Program Files\Autodesk\FBX\FBX SDK\2020.2.1\lib\vs2019\x64\release;%(AdditionalLibraryDirectories) diff --git a/Texture2DDecoderNative/Texture2DDecoderNative.vcxproj b/Texture2DDecoderNative/Texture2DDecoderNative.vcxproj index 3d90b0d..495ac84 100644 --- a/Texture2DDecoderNative/Texture2DDecoderNative.vcxproj +++ b/Texture2DDecoderNative/Texture2DDecoderNative.vcxproj @@ -67,26 +67,26 @@ DynamicLibrary true - v142 + v143 Unicode DynamicLibrary false - v142 + v143 true Unicode DynamicLibrary true - v142 + v143 Unicode DynamicLibrary false - v142 + v143 true Unicode From d220315d9bf4ee69805f7313cd1305d0fc777d38 Mon Sep 17 00:00:00 2001 From: Perfare Date: Thu, 9 Dec 2021 18:08:56 +0800 Subject: [PATCH 4/8] Add detailed export progress in the status bar --- AssetStudioGUI/Studio.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AssetStudioGUI/Studio.cs b/AssetStudioGUI/Studio.cs index fc56544..ab7caae 100644 --- a/AssetStudioGUI/Studio.cs +++ b/AssetStudioGUI/Studio.cs @@ -413,7 +413,7 @@ namespace AssetStudioGUI break; } exportPath += Path.DirectorySeparatorChar; - StatusStripUpdate($"Exporting {asset.TypeString}: {asset.Text}"); + StatusStripUpdate($"[{exportedCount}/{toExportCount}] Exporting {asset.TypeString}: {asset.Text}"); try { switch (exportType) From fe95c91759c33d4012aa536ca86ed153777f921f Mon Sep 17 00:00:00 2001 From: Perfare Date: Thu, 9 Dec 2021 19:00:59 +0800 Subject: [PATCH 5/8] Add net6.0 target framework --- .../AssetStudio.PInvoke.csproj | 2 +- AssetStudio/AssetStudio.csproj | 2 +- .../AssetStudioFBXWrapper.csproj | 2 +- AssetStudioGUI/AssetStudioGUI.csproj | 4 +-- AssetStudioGUI/Components/OpenFolderDialog.cs | 25 ++++++++++++------- AssetStudioUtility/AssetStudioUtility.csproj | 2 +- .../Texture2DDecoderWrapper.csproj | 2 +- 7 files changed, 23 insertions(+), 16 deletions(-) diff --git a/AssetStudio.PInvoke/AssetStudio.PInvoke.csproj b/AssetStudio.PInvoke/AssetStudio.PInvoke.csproj index b24e386..6e6b75f 100644 --- a/AssetStudio.PInvoke/AssetStudio.PInvoke.csproj +++ b/AssetStudio.PInvoke/AssetStudio.PInvoke.csproj @@ -1,7 +1,7 @@ - net472;netstandard2.0;net5.0 + net472;netstandard2.0;net5.0;net6.0 true 0.16.0.0 0.16.0.0 diff --git a/AssetStudio/AssetStudio.csproj b/AssetStudio/AssetStudio.csproj index 04a419c..afb240b 100644 --- a/AssetStudio/AssetStudio.csproj +++ b/AssetStudio/AssetStudio.csproj @@ -1,7 +1,7 @@ - net472;netstandard2.0;net5.0 + net472;netstandard2.0;net5.0;net6.0 0.16.0.0 0.16.0.0 0.16.0.0 diff --git a/AssetStudioFBXWrapper/AssetStudioFBXWrapper.csproj b/AssetStudioFBXWrapper/AssetStudioFBXWrapper.csproj index 9622f56..ea984fe 100644 --- a/AssetStudioFBXWrapper/AssetStudioFBXWrapper.csproj +++ b/AssetStudioFBXWrapper/AssetStudioFBXWrapper.csproj @@ -1,7 +1,7 @@ - net472;netstandard2.0;net5.0 + net472;netstandard2.0;net5.0;net6.0 true 0.16.0.0 0.16.0.0 diff --git a/AssetStudioGUI/AssetStudioGUI.csproj b/AssetStudioGUI/AssetStudioGUI.csproj index f08bfbb..3ace84a 100644 --- a/AssetStudioGUI/AssetStudioGUI.csproj +++ b/AssetStudioGUI/AssetStudioGUI.csproj @@ -2,7 +2,7 @@ WinExe - net472;net5.0-windows + net472;net5.0-windows;net6.0-windows true Resources\as.ico 0.16.0.0 @@ -51,7 +51,7 @@ - + Libraries\OpenTK.WinForms.dll diff --git a/AssetStudioGUI/Components/OpenFolderDialog.cs b/AssetStudioGUI/Components/OpenFolderDialog.cs index 3ffab13..cd8dcea 100644 --- a/AssetStudioGUI/Components/OpenFolderDialog.cs +++ b/AssetStudioGUI/Components/OpenFolderDialog.cs @@ -1,5 +1,4 @@ using System; -using System.IO; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Windows.Forms; @@ -15,12 +14,13 @@ namespace AssetStudioGUI internal DialogResult ShowDialog(IWin32Window owner = null) { +#if NETFRAMEWORK if (Environment.OSVersion.Version.Major >= 6) { return ShowVistaDialog(owner); } - - return ShowLegacyDialog(owner); +#endif + return ShowFolderBrowserDialog(owner); } private DialogResult ShowVistaDialog(IWin32Window owner) @@ -74,7 +74,7 @@ namespace AssetStudioGUI return DialogResult.Cancel; } - private DialogResult ShowLegacyDialog(IWin32Window owner) + private DialogResult ShowFolderBrowserDialog(IWin32Window owner) { using (var frm = new FolderBrowserDialog()) { @@ -82,13 +82,20 @@ namespace AssetStudioGUI { frm.SelectedPath = InitialFolder; } - if ((owner == null ? frm.ShowDialog() : frm.ShowDialog(owner)) == DialogResult.OK) +#if !NETFRAMEWORK + if (Title != null) { - Folder = Path.GetDirectoryName(frm.SelectedPath); - return DialogResult.OK; + frm.Description = Title; + frm.UseDescriptionForTitle = true; } - - return DialogResult.Cancel; +#endif + var result = owner == null ? frm.ShowDialog() : frm.ShowDialog(owner); + if (result == DialogResult.OK) + { + Folder = frm.SelectedPath; + return result; + } + return result; } } } diff --git a/AssetStudioUtility/AssetStudioUtility.csproj b/AssetStudioUtility/AssetStudioUtility.csproj index 9f39058..49bb7dc 100644 --- a/AssetStudioUtility/AssetStudioUtility.csproj +++ b/AssetStudioUtility/AssetStudioUtility.csproj @@ -1,7 +1,7 @@ - net472;netstandard2.0;net5.0 + net472;netstandard2.0;net5.0;net6.0 0.16.0.0 0.16.0.0 0.16.0.0 diff --git a/Texture2DDecoderWrapper/Texture2DDecoderWrapper.csproj b/Texture2DDecoderWrapper/Texture2DDecoderWrapper.csproj index 3dd9c79..c4f8839 100644 --- a/Texture2DDecoderWrapper/Texture2DDecoderWrapper.csproj +++ b/Texture2DDecoderWrapper/Texture2DDecoderWrapper.csproj @@ -1,7 +1,7 @@ - net472;netstandard2.0;net5.0 + net472;netstandard2.0;net5.0;net6.0 true 0.16.0.0 0.16.0.0 From 7295feda72963321df027a8ef58031b6a0407ad4 Mon Sep 17 00:00:00 2001 From: Perfare Date: Thu, 9 Dec 2021 19:16:13 +0800 Subject: [PATCH 6/8] Update README.md --- README.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 26529be..1135cb4 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,13 @@ AssetStudio is a tool for exploring, extracting and exporting assets and assetbu ## Requirements -- [.NET Framework 4.7.2](https://dotnet.microsoft.com/download/dotnet-framework/net472) +- AssetStudio.net472 + - [.NET Framework 4.7.2](https://dotnet.microsoft.com/download/dotnet-framework/net472) +- AssetStudio.net5 + - [.NET Desktop Runtime 5.0](https://dotnet.microsoft.com/download/dotnet/5.0) +- AssetStudio.net6 + - [.NET Desktop Runtime 6.0](https://dotnet.microsoft.com/download/dotnet/6.0) + ## Usage @@ -63,8 +69,8 @@ First, use my another program [Il2CppDumper](https://github.com/Perfare/Il2CppDu ## Build -* Visual Studio 2019 or newer -* **AssetStudioFBXNative** uses FBX SDK 2020.0.1 VS2017, before building, you need to install the FBX SDK and modify the project file, change include directory and library directory to point to the FBX SDK directory +* Visual Studio 2022 or newer +* **AssetStudioFBXNative** uses [FBX SDK 2020.2.1](https://www.autodesk.com/developer-network/platform-technologies/fbx-sdk-2020-2-1), before building, you need to install the FBX SDK and modify the project file, change include directory and library directory to point to the FBX SDK directory ## Open source libraries used From 97b5f51f3a7991cfeb24f2296b8a43408d838e92 Mon Sep 17 00:00:00 2001 From: Perfare Date: Thu, 9 Dec 2021 20:23:25 +0800 Subject: [PATCH 7/8] Fix build --- AssetStudio/AssetStudio.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AssetStudio/AssetStudio.csproj b/AssetStudio/AssetStudio.csproj index afb240b..e821b3c 100644 --- a/AssetStudio/AssetStudio.csproj +++ b/AssetStudio/AssetStudio.csproj @@ -8,7 +8,7 @@ Copyright © Perfare 2018-2021 - + From 0e1a886e0b1bae9d3e990b7b686e10f1c105e65d Mon Sep 17 00:00:00 2001 From: scriptkitz Date: Sat, 11 Dec 2021 15:48:54 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E4=BF=AE=E6=AD=A3UV=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98=E3=80=82?= =?UTF-8?q?=20(#891)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AssetStudioGUI/Exporter.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/AssetStudioGUI/Exporter.cs b/AssetStudioGUI/Exporter.cs index 6bc77ad..473ce78 100644 --- a/AssetStudioGUI/Exporter.cs +++ b/AssetStudioGUI/Exporter.cs @@ -152,6 +152,7 @@ namespace AssetStudioGUI #region UV if (m_Mesh.m_UV0?.Length > 0) { + c = 4; if (m_Mesh.m_UV0.Length == m_Mesh.m_VertexCount * 2) { c = 2;