Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8906c856e8 | ||
|
|
dec672f9e2 | ||
|
|
0b111d5f79 | ||
|
|
4bcbdbc57d | ||
|
|
d5d937247e | ||
|
|
4ab513002f | ||
|
|
140a732046 | ||
|
|
e5104d5cc7 | ||
|
|
f87390cc2b | ||
|
|
a062905734 | ||
|
|
62206f8977 | ||
|
|
8891414f60 | ||
|
|
90dce1c17d | ||
|
|
a9f1bd320e | ||
|
|
c8393e165f | ||
|
|
9d7c3b9f64 | ||
|
|
aa653cd508 | ||
|
|
3d60c5a7f6 | ||
|
|
4ef160de34 | ||
|
|
8f7def379d | ||
|
|
351228e45c | ||
|
|
ee6c050330 | ||
|
|
b4ce12a9e8 | ||
|
|
8664531c47 | ||
|
|
40f6dbcc06 | ||
|
|
1f21a67610 |
49
AssetStudio.sln
Normal file
49
AssetStudio.sln
Normal file
@@ -0,0 +1,49 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.27130.2024
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssetStudio", "AssetStudio\AssetStudio.csproj", "{24551E2D-E9B6-4CD6-8F2A-D9F4A13E7853}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssetStudio-x86", "AssetStudio\AssetStudio-x86.csproj", "{F5E07FB2-95E4-417F-943F-D439D9A03BBA}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AssetStudioFBX", "AssetStudioFBX\AssetStudioFBX.vcxproj", "{4F8EF5EF-732B-49CF-9EB3-B23E19AE6267}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssetStudioUtility", "AssetStudioUtility\AssetStudioUtility.csproj", "{9131C403-7FE8-444D-9AF5-5FE5DF76FF24}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AssetStudioFBX-x86", "AssetStudioFBX\AssetStudioFBX-x86.vcxproj", "{276DE52E-3FFE-4C3D-9076-62BCB7A5B991}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{24551E2D-E9B6-4CD6-8F2A-D9F4A13E7853}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{24551E2D-E9B6-4CD6-8F2A-D9F4A13E7853}.Debug|Any CPU.Build.0 = Debug|x64
|
||||
{24551E2D-E9B6-4CD6-8F2A-D9F4A13E7853}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{24551E2D-E9B6-4CD6-8F2A-D9F4A13E7853}.Release|Any CPU.Build.0 = Release|x64
|
||||
{F5E07FB2-95E4-417F-943F-D439D9A03BBA}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{F5E07FB2-95E4-417F-943F-D439D9A03BBA}.Debug|Any CPU.Build.0 = Debug|x86
|
||||
{F5E07FB2-95E4-417F-943F-D439D9A03BBA}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{F5E07FB2-95E4-417F-943F-D439D9A03BBA}.Release|Any CPU.Build.0 = Release|x86
|
||||
{4F8EF5EF-732B-49CF-9EB3-B23E19AE6267}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{4F8EF5EF-732B-49CF-9EB3-B23E19AE6267}.Debug|Any CPU.Build.0 = Debug|x64
|
||||
{4F8EF5EF-732B-49CF-9EB3-B23E19AE6267}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{4F8EF5EF-732B-49CF-9EB3-B23E19AE6267}.Release|Any CPU.Build.0 = Release|x64
|
||||
{9131C403-7FE8-444D-9AF5-5FE5DF76FF24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9131C403-7FE8-444D-9AF5-5FE5DF76FF24}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9131C403-7FE8-444D-9AF5-5FE5DF76FF24}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9131C403-7FE8-444D-9AF5-5FE5DF76FF24}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{276DE52E-3FFE-4C3D-9076-62BCB7A5B991}.Debug|Any CPU.ActiveCfg = Debug|Win32
|
||||
{276DE52E-3FFE-4C3D-9076-62BCB7A5B991}.Debug|Any CPU.Build.0 = Debug|Win32
|
||||
{276DE52E-3FFE-4C3D-9076-62BCB7A5B991}.Release|Any CPU.ActiveCfg = Release|Win32
|
||||
{276DE52E-3FFE-4C3D-9076-62BCB7A5B991}.Release|Any CPU.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {F5C476A6-2B3B-416F-8BD5-6FE454FF3972}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -8,8 +8,8 @@
|
||||
<ProjectGuid>{F5E07FB2-95E4-417F-943F-D439D9A03BBA}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Unity_Studio</RootNamespace>
|
||||
<AssemblyName>Unity Studio</AssemblyName>
|
||||
<RootNamespace>AssetStudio</RootNamespace>
|
||||
<AssemblyName>AssetStudio</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>
|
||||
</TargetFrameworkProfile>
|
||||
@@ -31,7 +31,8 @@
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>Resources\unity.ico</ApplicationIcon>
|
||||
<ApplicationIcon>
|
||||
</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
|
||||
@@ -55,21 +56,30 @@
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="BrotliSharpLib, Version=0.2.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>Library\BrotliSharpLib.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="OpenTK, Version=2.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>library\OpenTK.dll</HintPath>
|
||||
<HintPath>Library\OpenTK.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="OpenTK.GLControl, Version=1.1.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>library\OpenTK.GLControl.dll</HintPath>
|
||||
<HintPath>Library\OpenTK.GLControl.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="SharpDX.Mathematics">
|
||||
<HintPath>Library\SharpDX.Mathematics.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Half, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>library\System.Half.dll</HintPath>
|
||||
<HintPath>Library\System.Half.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
@@ -130,26 +140,47 @@
|
||||
<Compile Include="7zip\SevenZipHelper.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="AssetStudioForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="AssetStudioForm.Designer.cs">
|
||||
<DependentUpon>AssetStudioForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<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\Avatar.cs" />
|
||||
<Compile Include="OpenFolderDialog.cs" />
|
||||
<Compile Include="ShaderResource.Designer.cs">
|
||||
<Compile Include="Classes\AssetBundle.cs" />
|
||||
<Compile Include="Classes\MovieTexture.cs" />
|
||||
<Compile Include="Classes\Sprite.cs" />
|
||||
<Compile Include="Classes\SpriteAtlas.cs" />
|
||||
<Compile Include="Classes\VideoClip.cs" />
|
||||
<Compile Include="StudioClasses\AssetPreloadData.cs" />
|
||||
<Compile Include="Classes\AudioClip.cs" />
|
||||
<Compile Include="Classes\BuildSettings.cs" />
|
||||
<Compile Include="StudioClasses\BinaryReaderExtensions.cs" />
|
||||
<Compile Include="StudioClasses\BinaryWriterExtensions.cs" />
|
||||
<Compile Include="StudioClasses\BundleFile.cs" />
|
||||
<Compile Include="StudioClasses\ClassStruct.cs" />
|
||||
<Compile Include="StudioClasses\FBXExporter.cs" />
|
||||
<Compile Include="StudioClasses\BuildTarget.cs" />
|
||||
<Compile Include="StudioClasses\ModelConverter.cs" />
|
||||
<Compile Include="StudioClasses\ShaderResource.Designer.cs">
|
||||
<DependentUpon>ShaderResource.resx</DependentUpon>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<Compile Include="Unity Classes\AssetBundle.cs" />
|
||||
<Compile Include="Unity Classes\MovieTexture.cs" />
|
||||
<Compile Include="Unity Classes\Sprite.cs" />
|
||||
<Compile Include="Unity Classes\SpriteAtlas.cs" />
|
||||
<Compile Include="Unity Classes\VideoClip.cs" />
|
||||
<Compile Include="Unity Studio Classes\AssetPreloadData.cs" />
|
||||
<Compile Include="Unity Classes\AudioClip.cs" />
|
||||
<Compile Include="Unity Classes\BuildSettings.cs" />
|
||||
<Compile Include="Unity Studio Classes\BundleFile.cs" />
|
||||
<Compile Include="Unity Studio Classes\ClassStruct.cs" />
|
||||
<Compile Include="Unity Studio Classes\EndianBinaryReader.cs" />
|
||||
<Compile Include="Unity Studio Classes\UnityEnum.cs" />
|
||||
<Compile Include="Unity Studio Classes\UnityStudio.cs" />
|
||||
<Compile Include="Unity Studio Classes\ClassIDReference.cs" />
|
||||
<Compile Include="StudioClasses\SpriteHelper.cs" />
|
||||
<Compile Include="StudioClasses\StringExtensions.cs" />
|
||||
<Compile Include="StudioClasses\EndianBinaryReader.cs" />
|
||||
<Compile Include="Classes\Texture2D.Converter.cs" />
|
||||
<Compile Include="StudioClasses\Exporter.cs" />
|
||||
<Compile Include="StudioClasses\Importer.cs" />
|
||||
<Compile Include="StudioClasses\Studio.cs" />
|
||||
<Compile Include="StudioClasses\ClassIDReference.cs" />
|
||||
<Compile Include="ExportOptions.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@@ -159,34 +190,33 @@
|
||||
<Compile Include="FMOD Studio API\fmod.cs" />
|
||||
<Compile Include="FMOD Studio API\fmod_dsp.cs" />
|
||||
<Compile Include="FMOD Studio API\fmod_errors.cs" />
|
||||
<Compile Include="Unity Classes\Font.cs" />
|
||||
<Compile Include="Classes\Font.cs" />
|
||||
<Compile Include="GOHierarchy.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Unity Studio Classes\Lz4DecoderStream.cs" />
|
||||
<Compile Include="Unity Classes\Material.cs" />
|
||||
<Compile Include="Unity Classes\Mesh.cs" />
|
||||
<Compile Include="Unity Classes\GameObject.cs" />
|
||||
<Compile Include="Unity Studio Classes\Helpers.cs" />
|
||||
<Compile Include="Unity Classes\MonoBehaviour.cs" />
|
||||
<Compile Include="Unity Classes\PlayerSettings.cs" />
|
||||
<Compile Include="Unity Classes\RectTransform.cs" />
|
||||
<Compile Include="Unity Classes\MeshRenderer.cs" />
|
||||
<Compile Include="Unity Classes\Shader.cs" />
|
||||
<Compile Include="Unity Classes\SkinnedMeshRenderer.cs" />
|
||||
<Compile Include="Unity Classes\MeshFilter.cs" />
|
||||
<Compile Include="Unity Classes\TextAsset.cs" />
|
||||
<Compile Include="Unity Classes\Texture2D.cs" />
|
||||
<Compile Include="Unity Classes\Transform.cs" />
|
||||
<Compile Include="Lz4DecoderStream.cs" />
|
||||
<Compile Include="Classes\Material.cs" />
|
||||
<Compile Include="Classes\Mesh.cs" />
|
||||
<Compile Include="Classes\GameObject.cs" />
|
||||
<Compile Include="StudioClasses\PPtrHelpers.cs" />
|
||||
<Compile Include="Classes\MonoBehaviour.cs" />
|
||||
<Compile Include="Classes\PlayerSettings.cs" />
|
||||
<Compile Include="Classes\RectTransform.cs" />
|
||||
<Compile Include="Classes\MeshRenderer.cs" />
|
||||
<Compile Include="Classes\Shader.cs" />
|
||||
<Compile Include="Classes\SkinnedMeshRenderer.cs" />
|
||||
<Compile Include="Classes\MeshFilter.cs" />
|
||||
<Compile Include="Classes\TextAsset.cs" />
|
||||
<Compile Include="Classes\Texture2D.cs" />
|
||||
<Compile Include="Classes\Transform.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Unity Studio Classes\AssetsFile.cs" />
|
||||
<Compile Include="UnityStudioForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UnityStudioForm.Designer.cs">
|
||||
<DependentUpon>UnityStudioForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="StudioClasses\AssetsFile.cs" />
|
||||
<Compile Include="StudioClasses\WebFile.cs" />
|
||||
<EmbeddedResource Include="AssetStudioForm.resx">
|
||||
<DependentUpon>AssetStudioForm.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="ExportOptions.resx">
|
||||
<DependentUpon>ExportOptions.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
@@ -200,14 +230,10 @@
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="ShaderResource.resx">
|
||||
<EmbeddedResource Include="StudioClasses\ShaderResource.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>ShaderResource.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="UnityStudioForm.resx">
|
||||
<DependentUpon>UnityStudioForm.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<None Include="app.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
@@ -237,15 +263,22 @@
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\unity.ico" />
|
||||
<None Include="Resources\preview.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\preview.png" />
|
||||
<ProjectReference Include="..\AssetStudioFBX\AssetStudioFBX-x86.vcxproj">
|
||||
<Project>{276de52e-3ffe-4c3d-9076-62bcb7a5b991}</Project>
|
||||
<Name>AssetStudioFBX-x86</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\AssetStudioUtility\AssetStudioUtility.csproj">
|
||||
<Project>{9131c403-7fe8-444d-9af5-5fe5df76ff24}</Project>
|
||||
<Name>AssetStudioUtility</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>xcopy /y "$(ProjectDir)library" "$(TargetDir)"
|
||||
xcopy /y "$(ProjectDir)library\$(PlatformName)" "$(TargetDir)"</PostBuildEvent>
|
||||
<PostBuildEvent>xcopy /y "$(ProjectDir)Library" "$(TargetDir)"
|
||||
xcopy /y "$(ProjectDir)Library\$(PlatformName)" "$(TargetDir)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
@@ -8,8 +8,8 @@
|
||||
<ProjectGuid>{24551E2D-E9B6-4CD6-8F2A-D9F4A13E7853}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Unity_Studio</RootNamespace>
|
||||
<AssemblyName>Unity Studio</AssemblyName>
|
||||
<RootNamespace>AssetStudio</RootNamespace>
|
||||
<AssemblyName>AssetStudio</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>
|
||||
</TargetFrameworkProfile>
|
||||
@@ -31,7 +31,8 @@
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>Resources\unity.ico</ApplicationIcon>
|
||||
<ApplicationIcon>
|
||||
</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -55,21 +56,30 @@
|
||||
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="BrotliSharpLib, Version=0.2.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>Library\BrotliSharpLib.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="OpenTK, Version=2.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>library\OpenTK.dll</HintPath>
|
||||
<HintPath>Library\OpenTK.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="OpenTK.GLControl, Version=1.1.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>library\OpenTK.GLControl.dll</HintPath>
|
||||
<HintPath>Library\OpenTK.GLControl.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="SharpDX.Mathematics">
|
||||
<HintPath>Library\SharpDX.Mathematics.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Half, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>library\System.Half.dll</HintPath>
|
||||
<HintPath>Library\System.Half.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
@@ -130,26 +140,40 @@
|
||||
<Compile Include="7zip\SevenZipHelper.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<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\Avatar.cs" />
|
||||
<Compile Include="OpenFolderDialog.cs" />
|
||||
<Compile Include="ShaderResource.Designer.cs">
|
||||
<Compile Include="StudioClasses\BinaryReaderExtensions.cs" />
|
||||
<Compile Include="StudioClasses\BinaryWriterExtensions.cs" />
|
||||
<Compile Include="StudioClasses\BuildTarget.cs" />
|
||||
<Compile Include="StudioClasses\ClassIDReference.cs" />
|
||||
<Compile Include="StudioClasses\ShaderResource.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>ShaderResource.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Unity Classes\AssetBundle.cs" />
|
||||
<Compile Include="Unity Classes\MovieTexture.cs" />
|
||||
<Compile Include="Unity Classes\Sprite.cs" />
|
||||
<Compile Include="Unity Classes\SpriteAtlas.cs" />
|
||||
<Compile Include="Unity Classes\VideoClip.cs" />
|
||||
<Compile Include="Unity Studio Classes\AssetPreloadData.cs" />
|
||||
<Compile Include="Unity Classes\AudioClip.cs" />
|
||||
<Compile Include="Unity Classes\BuildSettings.cs" />
|
||||
<Compile Include="Unity Studio Classes\BundleFile.cs" />
|
||||
<Compile Include="Unity Studio Classes\ClassStruct.cs" />
|
||||
<Compile Include="Unity Studio Classes\UnityEnum.cs" />
|
||||
<Compile Include="Unity Studio Classes\UnityStudio.cs" />
|
||||
<Compile Include="Unity Studio Classes\ClassIDReference.cs" />
|
||||
<Compile Include="Unity Studio Classes\EndianBinaryReader.cs" />
|
||||
<Compile Include="Classes\AssetBundle.cs" />
|
||||
<Compile Include="Classes\MovieTexture.cs" />
|
||||
<Compile Include="Classes\Sprite.cs" />
|
||||
<Compile Include="Classes\SpriteAtlas.cs" />
|
||||
<Compile Include="Classes\VideoClip.cs" />
|
||||
<Compile Include="StudioClasses\AssetPreloadData.cs" />
|
||||
<Compile Include="Classes\AudioClip.cs" />
|
||||
<Compile Include="Classes\BuildSettings.cs" />
|
||||
<Compile Include="StudioClasses\BundleFile.cs" />
|
||||
<Compile Include="StudioClasses\ClassStruct.cs" />
|
||||
<Compile Include="StudioClasses\FBXExporter.cs" />
|
||||
<Compile Include="StudioClasses\SpriteHelper.cs" />
|
||||
<Compile Include="StudioClasses\StringExtensions.cs" />
|
||||
<Compile Include="Classes\Texture2D.Converter.cs" />
|
||||
<Compile Include="StudioClasses\Exporter.cs" />
|
||||
<Compile Include="StudioClasses\Importer.cs" />
|
||||
<Compile Include="StudioClasses\Studio.cs" />
|
||||
<Compile Include="StudioClasses\EndianBinaryReader.cs" />
|
||||
<Compile Include="ExportOptions.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@@ -159,33 +183,35 @@
|
||||
<Compile Include="FMOD Studio API\fmod.cs" />
|
||||
<Compile Include="FMOD Studio API\fmod_dsp.cs" />
|
||||
<Compile Include="FMOD Studio API\fmod_errors.cs" />
|
||||
<Compile Include="Unity Classes\Font.cs" />
|
||||
<Compile Include="Classes\Font.cs" />
|
||||
<Compile Include="GOHierarchy.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Unity Studio Classes\Lz4DecoderStream.cs" />
|
||||
<Compile Include="Unity Classes\Material.cs" />
|
||||
<Compile Include="Unity Classes\Mesh.cs" />
|
||||
<Compile Include="Unity Classes\GameObject.cs" />
|
||||
<Compile Include="Unity Studio Classes\Helpers.cs" />
|
||||
<Compile Include="Unity Classes\MonoBehaviour.cs" />
|
||||
<Compile Include="Unity Classes\PlayerSettings.cs" />
|
||||
<Compile Include="Unity Classes\RectTransform.cs" />
|
||||
<Compile Include="Unity Classes\MeshRenderer.cs" />
|
||||
<Compile Include="Unity Classes\Shader.cs" />
|
||||
<Compile Include="Unity Classes\SkinnedMeshRenderer.cs" />
|
||||
<Compile Include="Unity Classes\MeshFilter.cs" />
|
||||
<Compile Include="Unity Classes\TextAsset.cs" />
|
||||
<Compile Include="Unity Classes\Texture2D.cs" />
|
||||
<Compile Include="Unity Classes\Transform.cs" />
|
||||
<Compile Include="Lz4DecoderStream.cs" />
|
||||
<Compile Include="Classes\Material.cs" />
|
||||
<Compile Include="Classes\Mesh.cs" />
|
||||
<Compile Include="Classes\GameObject.cs" />
|
||||
<Compile Include="StudioClasses\PPtrHelpers.cs" />
|
||||
<Compile Include="Classes\MonoBehaviour.cs" />
|
||||
<Compile Include="Classes\PlayerSettings.cs" />
|
||||
<Compile Include="Classes\RectTransform.cs" />
|
||||
<Compile Include="Classes\MeshRenderer.cs" />
|
||||
<Compile Include="Classes\Shader.cs" />
|
||||
<Compile Include="Classes\SkinnedMeshRenderer.cs" />
|
||||
<Compile Include="Classes\MeshFilter.cs" />
|
||||
<Compile Include="Classes\TextAsset.cs" />
|
||||
<Compile Include="Classes\Texture2D.cs" />
|
||||
<Compile Include="Classes\Transform.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Unity Studio Classes\AssetsFile.cs" />
|
||||
<Compile Include="UnityStudioForm.cs">
|
||||
<Compile Include="StudioClasses\AssetsFile.cs" />
|
||||
<Compile Include="StudioClasses\ModelConverter.cs" />
|
||||
<Compile Include="StudioClasses\WebFile.cs" />
|
||||
<Compile Include="AssetStudioForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UnityStudioForm.Designer.cs">
|
||||
<DependentUpon>UnityStudioForm.cs</DependentUpon>
|
||||
<Compile Include="AssetStudioForm.Designer.cs">
|
||||
<DependentUpon>AssetStudioForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="ExportOptions.resx">
|
||||
<DependentUpon>ExportOptions.cs</DependentUpon>
|
||||
@@ -200,17 +226,15 @@
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="ShaderResource.resx">
|
||||
<EmbeddedResource Include="StudioClasses\ShaderResource.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>ShaderResource.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="UnityStudioForm.resx">
|
||||
<DependentUpon>UnityStudioForm.cs</DependentUpon>
|
||||
<EmbeddedResource Include="AssetStudioForm.resx">
|
||||
<DependentUpon>AssetStudioForm.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<None Include="app.config">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<None Include="app.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
@@ -242,12 +266,19 @@
|
||||
<None Include="Resources\preview.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\unity.ico" />
|
||||
<ProjectReference Include="..\AssetStudioFBX\AssetStudioFBX.vcxproj">
|
||||
<Project>{4f8ef5ef-732b-49cf-9eb3-b23e19ae6267}</Project>
|
||||
<Name>AssetStudioFBX</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\AssetStudioUtility\AssetStudioUtility.csproj">
|
||||
<Project>{9131c403-7fe8-444d-9af5-5fe5df76ff24}</Project>
|
||||
<Name>AssetStudioUtility</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>xcopy /y "$(ProjectDir)library" "$(TargetDir)"
|
||||
xcopy /y "$(ProjectDir)library\$(PlatformName)" "$(TargetDir)"</PostBuildEvent>
|
||||
<PostBuildEvent>xcopy /y "$(ProjectDir)Library" "$(TargetDir)"
|
||||
xcopy /y "$(ProjectDir)Library\$(PlatformName)" "$(TargetDir)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Unity_Studio
|
||||
namespace AssetStudio
|
||||
{
|
||||
partial class UnityStudioForm
|
||||
partial class AssetStudioForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@@ -29,7 +29,7 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(UnityStudioForm));
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AssetStudioForm));
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.loadFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
@@ -62,7 +62,7 @@
|
||||
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
||||
this.tabControl1 = new System.Windows.Forms.TabControl();
|
||||
this.tabPage1 = new System.Windows.Forms.TabPage();
|
||||
this.sceneTreeView = new Unity_Studio.GOHierarchy();
|
||||
this.sceneTreeView = new GOHierarchy();
|
||||
this.treeSearch = new System.Windows.Forms.TextBox();
|
||||
this.tabPage2 = new System.Windows.Forms.TabPage();
|
||||
this.assetListView = new System.Windows.Forms.ListView();
|
||||
@@ -103,6 +103,8 @@
|
||||
this.treeTip = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.showOriginalFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.animatorWithAnimationClipToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
|
||||
this.splitContainer1.Panel1.SuspendLayout();
|
||||
@@ -317,7 +319,9 @@
|
||||
this.exportToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.exportAllAssetsMenuItem,
|
||||
this.exportSelectedAssetsMenuItem,
|
||||
this.exportFilteredAssetsMenuItem});
|
||||
this.exportFilteredAssetsMenuItem,
|
||||
this.toolStripSeparator1,
|
||||
this.animatorWithAnimationClipToolStripMenuItem});
|
||||
this.exportToolStripMenuItem.Name = "exportToolStripMenuItem";
|
||||
this.exportToolStripMenuItem.Size = new System.Drawing.Size(58, 21);
|
||||
this.exportToolStripMenuItem.Text = "Export";
|
||||
@@ -535,7 +539,7 @@
|
||||
// previewPanel
|
||||
//
|
||||
this.previewPanel.BackColor = System.Drawing.SystemColors.ControlDark;
|
||||
this.previewPanel.BackgroundImage = global::Unity_Studio.Properties.Resources.preview;
|
||||
this.previewPanel.BackgroundImage = global::AssetStudio.Properties.Resources.preview;
|
||||
this.previewPanel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
|
||||
this.previewPanel.Controls.Add(this.assetInfoLabel);
|
||||
this.previewPanel.Controls.Add(this.FMODpanel);
|
||||
@@ -813,7 +817,7 @@
|
||||
// openFileDialog1
|
||||
//
|
||||
this.openFileDialog1.AddExtension = false;
|
||||
this.openFileDialog1.Filter = resources.GetString("openFileDialog1.Filter");
|
||||
this.openFileDialog1.Filter = "All types|*.*";
|
||||
this.openFileDialog1.Multiselect = true;
|
||||
this.openFileDialog1.RestoreDirectory = true;
|
||||
//
|
||||
@@ -837,21 +841,32 @@
|
||||
this.showOriginalFileToolStripMenuItem.Text = "show original file";
|
||||
this.showOriginalFileToolStripMenuItem.Click += new System.EventHandler(this.showOriginalFileToolStripMenuItem_Click);
|
||||
//
|
||||
// UnityStudioForm
|
||||
// toolStripSeparator1
|
||||
//
|
||||
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||
this.toolStripSeparator1.Size = new System.Drawing.Size(162, 6);
|
||||
//
|
||||
// animatorWithAnimationClipToolStripMenuItem
|
||||
//
|
||||
this.animatorWithAnimationClipToolStripMenuItem.Name = "animatorWithAnimationClipToolStripMenuItem";
|
||||
this.animatorWithAnimationClipToolStripMenuItem.Size = new System.Drawing.Size(240, 22);
|
||||
this.animatorWithAnimationClipToolStripMenuItem.Text = "Export Animator with AnimationClip";
|
||||
this.animatorWithAnimationClipToolStripMenuItem.Click += new System.EventHandler(this.ExportAnimatorwithAnimationClip_Click);
|
||||
//
|
||||
// AssetStudioForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1264, 681);
|
||||
this.Controls.Add(this.splitContainer1);
|
||||
this.Controls.Add(this.menuStrip1);
|
||||
this.Icon = global::Unity_Studio.Properties.Resources.unity;
|
||||
this.KeyPreview = true;
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
this.MinimumSize = new System.Drawing.Size(620, 372);
|
||||
this.Name = "UnityStudioForm";
|
||||
this.Name = "AssetStudioForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Unity Studio";
|
||||
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.UnityStudioForm_KeyDown);
|
||||
this.Text = "AssetStudio";
|
||||
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.AssetStudioForm_KeyDown);
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
this.splitContainer1.Panel1.ResumeLayout(false);
|
||||
@@ -957,6 +972,8 @@
|
||||
private OpenTK.GLControl glControl1;
|
||||
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
|
||||
private System.Windows.Forms.ToolStripMenuItem showOriginalFileToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||
private System.Windows.Forms.ToolStripMenuItem animatorWithAnimationClipToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,11 +13,15 @@ using System.Diagnostics;
|
||||
using System.Drawing.Text;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using static Unity_Studio.UnityStudio;
|
||||
using static AssetStudio.Studio;
|
||||
using static AssetStudio.FBXExporter;
|
||||
using static AssetStudio.Importer;
|
||||
using static AssetStudio.Exporter;
|
||||
using static AssetStudio.SpriteHelper;
|
||||
|
||||
namespace Unity_Studio
|
||||
namespace AssetStudio
|
||||
{
|
||||
partial class UnityStudioForm : Form
|
||||
partial class AssetStudioForm : Form
|
||||
{
|
||||
private AssetPreloadData lastSelectedItem;
|
||||
private AssetPreloadData lastLoadedAsset;
|
||||
@@ -84,58 +88,24 @@ namespace Unity_Studio
|
||||
resetForm();
|
||||
ThreadPool.QueueUserWorkItem(state =>
|
||||
{
|
||||
var bundle = false;
|
||||
if (openFileDialog1.FilterIndex == 1 || openFileDialog1.FilterIndex == 3)
|
||||
mainPath = Path.GetDirectoryName(openFileDialog1.FileNames[0]);
|
||||
MergeSplitAssets(mainPath);
|
||||
var readFile = ProcessingSplitFiles(openFileDialog1.FileNames.ToList());
|
||||
foreach (var i in readFile)
|
||||
{
|
||||
if (CheckBundleFile(openFileDialog1.FileNames[0]))
|
||||
{
|
||||
if (openFileDialog1.FileNames.Length > 1)
|
||||
{
|
||||
MessageBox.Show($"{Path.GetFileName(openFileDialog1.FileNames[0])} is bundle file, please select bundle file type to load this file");
|
||||
return;
|
||||
}
|
||||
bundle = true;
|
||||
}
|
||||
importFiles.Add(i);
|
||||
importFilesHash.Add(Path.GetFileName(i).ToUpper());
|
||||
}
|
||||
else
|
||||
SetProgressBarValue(0);
|
||||
SetProgressBarMaximum(importFiles.Count);
|
||||
//use a for loop because list size can change
|
||||
for (int f = 0; f < importFiles.Count; f++)
|
||||
{
|
||||
bundle = true;
|
||||
LoadFile(importFiles[f]);
|
||||
ProgressBarPerformStep();
|
||||
}
|
||||
if (!bundle)
|
||||
{
|
||||
mainPath = Path.GetDirectoryName(openFileDialog1.FileNames[0]);
|
||||
MergeSplitAssets(mainPath);
|
||||
var readFile = ProcessingSplitFiles(openFileDialog1.FileNames.ToList());
|
||||
foreach (var i in readFile)
|
||||
{
|
||||
unityFiles.Add(i);
|
||||
unityFilesHash.Add(Path.GetFileName(i));
|
||||
}
|
||||
SetProgressBarValue(0);
|
||||
SetProgressBarMaximum(unityFiles.Count);
|
||||
//use a for loop because list size can change
|
||||
for (int f = 0; f < unityFiles.Count; f++)
|
||||
{
|
||||
var fileName = unityFiles[f];
|
||||
StatusStripUpdate("Loading " + Path.GetFileName(fileName));
|
||||
LoadAssetsFile(fileName);
|
||||
ProgressBarPerformStep();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SetProgressBarValue(0);
|
||||
SetProgressBarMaximum(unityFiles.Count);
|
||||
foreach (var filename in openFileDialog1.FileNames)
|
||||
{
|
||||
LoadBundleFile(filename);
|
||||
ProgressBarPerformStep();
|
||||
}
|
||||
BuildSharedIndex();
|
||||
}
|
||||
unityFilesHash.Clear();
|
||||
importFilesHash.Clear();
|
||||
assetsfileListHash.Clear();
|
||||
sharedFileIndex.Clear();
|
||||
BuildAssetStrucutres();
|
||||
});
|
||||
}
|
||||
@@ -155,22 +125,19 @@ namespace Unity_Studio
|
||||
var readFile = ProcessingSplitFiles(files);
|
||||
foreach (var i in readFile)
|
||||
{
|
||||
unityFiles.Add(i);
|
||||
unityFilesHash.Add(Path.GetFileName(i));
|
||||
importFiles.Add(i);
|
||||
importFilesHash.Add(Path.GetFileName(i));
|
||||
}
|
||||
SetProgressBarValue(0);
|
||||
SetProgressBarMaximum(unityFiles.Count);
|
||||
SetProgressBarMaximum(importFiles.Count);
|
||||
//use a for loop because list size can change
|
||||
for (int f = 0; f < unityFiles.Count; f++)
|
||||
for (int f = 0; f < importFiles.Count; f++)
|
||||
{
|
||||
var fileName = unityFiles[f];
|
||||
StatusStripUpdate("Loading " + Path.GetFileName(fileName));
|
||||
LoadAssetsFile(fileName);
|
||||
LoadFile(importFiles[f]);
|
||||
ProgressBarPerformStep();
|
||||
}
|
||||
unityFilesHash.Clear();
|
||||
importFilesHash.Clear();
|
||||
assetsfileListHash.Clear();
|
||||
sharedFileIndex.Clear();
|
||||
BuildAssetStrucutres();
|
||||
});
|
||||
}
|
||||
@@ -179,7 +146,7 @@ namespace Unity_Studio
|
||||
private void extractBundleToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
OpenFileDialog openBundleDialog = new OpenFileDialog();
|
||||
openBundleDialog.Filter = "Unity bundle files|*.*";
|
||||
openBundleDialog.Filter = "Bundle files|*.*";
|
||||
openBundleDialog.FilterIndex = 1;
|
||||
openBundleDialog.RestoreDirectory = true;
|
||||
openBundleDialog.Multiselect = true;
|
||||
@@ -193,7 +160,7 @@ namespace Unity_Studio
|
||||
{
|
||||
foreach (var fileName in openBundleDialog.FileNames)
|
||||
{
|
||||
extractedCount += extractBundleFile(fileName);
|
||||
extractedCount += ExtractBundleFile(fileName);
|
||||
ProgressBarPerformStep();
|
||||
}
|
||||
StatusStripUpdate($"Finished extracting {extractedCount} files.");
|
||||
@@ -215,7 +182,7 @@ namespace Unity_Studio
|
||||
{
|
||||
foreach (var fileName in bundleFiles)
|
||||
{
|
||||
extractedCount += extractBundleFile(fileName);
|
||||
extractedCount += ExtractBundleFile(fileName);
|
||||
ProgressBarPerformStep();
|
||||
}
|
||||
StatusStripUpdate($"Finished extracting {extractedCount} files.");
|
||||
@@ -236,11 +203,11 @@ namespace Unity_Studio
|
||||
{
|
||||
if (productName != "")
|
||||
{
|
||||
Text = $"Unity Studio - {productName} - {assetsfileList[0].m_Version} - {assetsfileList[0].platformStr}";
|
||||
Text = $"AssetStudio - {productName} - {assetsfileList[0].m_Version} - {assetsfileList[0].platformStr}";
|
||||
}
|
||||
else if (assetsfileList.Count > 0)
|
||||
{
|
||||
Text = $"Unity Studio - no productName - {assetsfileList[0].m_Version} - {assetsfileList[0].platformStr}";
|
||||
Text = $"AssetStudio - no productName - {assetsfileList[0].m_Version} - {assetsfileList[0].platformStr}";
|
||||
}
|
||||
if (!dontLoadAssetsMenuItem.Checked)
|
||||
{
|
||||
@@ -276,7 +243,7 @@ namespace Unity_Studio
|
||||
}));
|
||||
}
|
||||
|
||||
private void UnityStudioForm_KeyDown(object sender, KeyEventArgs e)
|
||||
private void AssetStudioForm_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Control && e.Alt && e.KeyCode == Keys.D)
|
||||
{
|
||||
@@ -421,10 +388,10 @@ namespace Unity_Studio
|
||||
{
|
||||
if (lastLoadedAsset != null)
|
||||
{
|
||||
switch (lastLoadedAsset.Type2)
|
||||
switch (lastLoadedAsset.Type)
|
||||
{
|
||||
case 28:
|
||||
case 213:
|
||||
case ClassIDReference.Texture2D:
|
||||
case ClassIDReference.Sprite:
|
||||
{
|
||||
if (enablePreview.Checked && imageTexture != null)
|
||||
{
|
||||
@@ -437,15 +404,15 @@ namespace Unity_Studio
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 48:
|
||||
case 49:
|
||||
case 114:
|
||||
case ClassIDReference.Shader:
|
||||
case ClassIDReference.TextAsset:
|
||||
case ClassIDReference.MonoBehaviour:
|
||||
textPreviewBox.Visible = !textPreviewBox.Visible;
|
||||
break;
|
||||
case 128:
|
||||
case ClassIDReference.Font:
|
||||
fontPreviewBox.Visible = !fontPreviewBox.Visible;
|
||||
break;
|
||||
case 83:
|
||||
case ClassIDReference.AudioClip:
|
||||
{
|
||||
FMODpanel.Visible = !FMODpanel.Visible;
|
||||
|
||||
@@ -761,10 +728,9 @@ namespace Unity_Studio
|
||||
|
||||
private void PreviewAsset(AssetPreloadData asset)
|
||||
{
|
||||
switch (asset.Type2)
|
||||
switch (asset.Type)
|
||||
{
|
||||
#region Texture2D
|
||||
case 28: //Texture2D
|
||||
case ClassIDReference.Texture2D:
|
||||
{
|
||||
imageTexture?.Dispose();
|
||||
var m_Texture2D = new Texture2D(asset, true);
|
||||
@@ -783,9 +749,7 @@ namespace Unity_Studio
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endregion
|
||||
#region AudioClip
|
||||
case 83: //AudioClip
|
||||
case ClassIDReference.AudioClip:
|
||||
{
|
||||
AudioClip m_AudioClip = new AudioClip(asset, true);
|
||||
if (m_AudioClip.m_AudioData == null)
|
||||
@@ -819,9 +783,7 @@ namespace Unity_Studio
|
||||
FMODtimerLabel.Text = $"0:0.0 / {FMODlenms / 1000 / 60}:{FMODlenms / 1000 % 60}.{FMODlenms / 10 % 100}";
|
||||
break;
|
||||
}
|
||||
#endregion
|
||||
#region Shader
|
||||
case 48:
|
||||
case ClassIDReference.Shader:
|
||||
{
|
||||
Shader m_TextAsset = new Shader(asset, true);
|
||||
string m_Script_Text = Encoding.UTF8.GetString(m_TextAsset.m_Script);
|
||||
@@ -831,9 +793,7 @@ namespace Unity_Studio
|
||||
textPreviewBox.Visible = true;
|
||||
break;
|
||||
}
|
||||
#endregion
|
||||
#region TextAsset
|
||||
case 49:
|
||||
case ClassIDReference.TextAsset:
|
||||
{
|
||||
TextAsset m_TextAsset = new TextAsset(asset, true);
|
||||
|
||||
@@ -844,9 +804,7 @@ namespace Unity_Studio
|
||||
|
||||
break;
|
||||
}
|
||||
#endregion
|
||||
#region MonoBehaviour
|
||||
case 114:
|
||||
case ClassIDReference.MonoBehaviour:
|
||||
{
|
||||
MonoBehaviour m_MonoBehaviour = new MonoBehaviour(asset, true);
|
||||
textPreviewBox.Text = m_MonoBehaviour.serializedText;
|
||||
@@ -854,11 +812,9 @@ namespace Unity_Studio
|
||||
|
||||
break;
|
||||
}
|
||||
#endregion
|
||||
#region Font
|
||||
case 128: //Font
|
||||
case ClassIDReference.Font:
|
||||
{
|
||||
unityFont m_Font = new unityFont(asset, true);
|
||||
UFont m_Font = new UFont(asset, true);
|
||||
if (m_Font.m_FontData != null)
|
||||
{
|
||||
IntPtr data = Marshal.AllocCoTaskMem(m_Font.m_FontData.Length);
|
||||
@@ -908,9 +864,7 @@ namespace Unity_Studio
|
||||
StatusStripUpdate("Unsupported font for preview. Try to export.");
|
||||
break;
|
||||
}
|
||||
#endregion
|
||||
#region Mesh
|
||||
case 43: //Mesh
|
||||
case ClassIDReference.Mesh:
|
||||
{
|
||||
var m_Mesh = new Mesh(asset, true);
|
||||
if (m_Mesh.m_VertexCount > 0)
|
||||
@@ -1011,7 +965,7 @@ namespace Unity_Studio
|
||||
}
|
||||
#endregion
|
||||
#region Colors
|
||||
if (m_Mesh.m_Colors == null)
|
||||
if (m_Mesh.m_Colors == null || m_Mesh.m_Colors.Length == 0)
|
||||
{
|
||||
colorData = new Vector4[m_Mesh.m_VertexCount];
|
||||
for (int c = 0; c < m_Mesh.m_VertexCount; c++)
|
||||
@@ -1051,17 +1005,13 @@ namespace Unity_Studio
|
||||
+ "'Ctrl W'=Wireframe | 'Ctrl S'=Shade | 'Ctrl N'=ReNormal ");
|
||||
}
|
||||
break;
|
||||
#endregion
|
||||
#region VideoClip and MovieTexture
|
||||
case 329: //VideoClip
|
||||
case 152: //MovieTexture
|
||||
case ClassIDReference.VideoClip:
|
||||
case ClassIDReference.MovieTexture:
|
||||
{
|
||||
StatusStripUpdate("Only supported export.");
|
||||
break;
|
||||
}
|
||||
#endregion
|
||||
#region Sprite
|
||||
case 213: //Sprite
|
||||
case ClassIDReference.Sprite:
|
||||
{
|
||||
imageTexture?.Dispose();
|
||||
imageTexture = GetImageFromSprite(asset);
|
||||
@@ -1075,11 +1025,20 @@ namespace Unity_Studio
|
||||
}
|
||||
else
|
||||
{
|
||||
StatusStripUpdate("Unsupported sprite for preview");
|
||||
StatusStripUpdate("Unsupported sprite for preview.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endregion
|
||||
case ClassIDReference.Animator:
|
||||
{
|
||||
StatusStripUpdate("Can be exported as a FBX file.");
|
||||
break;
|
||||
}
|
||||
case ClassIDReference.AnimationClip:
|
||||
{
|
||||
StatusStripUpdate("Select AnimationClip with selecting Animator to export");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
var str = asset.ViewStruct();
|
||||
@@ -1486,7 +1445,7 @@ namespace Unity_Studio
|
||||
break;
|
||||
case "exportSelectedAssetsMenuItem":
|
||||
toExportAssets = new List<AssetPreloadData>(assetListView.SelectedIndices.Count);
|
||||
foreach (var i in assetListView.SelectedIndices.OfType<int>())
|
||||
foreach (int i in assetListView.SelectedIndices)
|
||||
{
|
||||
toExportAssets.Add((AssetPreloadData)assetListView.Items[i]);
|
||||
}
|
||||
@@ -1512,68 +1471,74 @@ namespace Unity_Studio
|
||||
if (assetGroupSelectedIndex == 1) { exportpath += Path.GetFileNameWithoutExtension(asset.sourceFile.filePath) + "_export\\"; }
|
||||
else if (assetGroupSelectedIndex == 0) { exportpath = savePath + "\\" + asset.TypeString + "\\"; }
|
||||
StatusStripUpdate($"Exporting {asset.TypeString}: {asset.Text}");
|
||||
switch (asset.Type2)
|
||||
switch (asset.Type)
|
||||
{
|
||||
case 28: //Texture2D
|
||||
case ClassIDReference.Texture2D:
|
||||
if (ExportTexture2D(asset, exportpath, true))
|
||||
{
|
||||
exportedCount++;
|
||||
}
|
||||
break;
|
||||
case 83: //AudioClip
|
||||
case ClassIDReference.AudioClip:
|
||||
if (ExportAudioClip(asset, exportpath))
|
||||
{
|
||||
exportedCount++;
|
||||
}
|
||||
break;
|
||||
case 48: //Shader
|
||||
case ClassIDReference.Shader:
|
||||
if (ExportShader(asset, exportpath))
|
||||
{
|
||||
exportedCount++;
|
||||
}
|
||||
break;
|
||||
case 49: //TextAsset
|
||||
case ClassIDReference.TextAsset:
|
||||
if (ExportTextAsset(asset, exportpath))
|
||||
{
|
||||
exportedCount++;
|
||||
}
|
||||
break;
|
||||
case 114: //MonoBehaviour
|
||||
case ClassIDReference.MonoBehaviour:
|
||||
if (ExportMonoBehaviour(asset, exportpath))
|
||||
{
|
||||
exportedCount++;
|
||||
}
|
||||
break;
|
||||
case 128: //Font
|
||||
case ClassIDReference.Font:
|
||||
if (ExportFont(asset, exportpath))
|
||||
{
|
||||
exportedCount++;
|
||||
}
|
||||
break;
|
||||
case 43: //Mesh
|
||||
case ClassIDReference.Mesh:
|
||||
if (ExportMesh(asset, exportpath))
|
||||
{
|
||||
exportedCount++;
|
||||
}
|
||||
break;
|
||||
case 329: //VideoClip
|
||||
case ClassIDReference.VideoClip:
|
||||
if (ExportVideoClip(asset, exportpath))
|
||||
{
|
||||
exportedCount++;
|
||||
}
|
||||
break;
|
||||
case 152: //MovieTexture
|
||||
case ClassIDReference.MovieTexture:
|
||||
if (ExportMovieTexture(asset, exportpath))
|
||||
{
|
||||
exportedCount++;
|
||||
}
|
||||
break;
|
||||
case 213: //Sprite
|
||||
case ClassIDReference.Sprite:
|
||||
if (ExportSprite(asset, exportpath))
|
||||
{
|
||||
exportedCount++;
|
||||
}
|
||||
break;
|
||||
case ClassIDReference.Animator:
|
||||
if (ExportAnimator(asset, exportpath))
|
||||
{
|
||||
exportedCount++;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (ExportRawFile(asset, exportpath))
|
||||
{
|
||||
@@ -1668,7 +1633,7 @@ namespace Unity_Studio
|
||||
}
|
||||
}
|
||||
|
||||
public UnityStudioForm()
|
||||
public AssetStudioForm()
|
||||
{
|
||||
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
|
||||
InitializeComponent();
|
||||
@@ -1680,11 +1645,11 @@ namespace Unity_Studio
|
||||
assetGroupOptions.SelectedIndex = (int)Properties.Settings.Default["assetGroupOption"];
|
||||
FMODinit();
|
||||
//UI
|
||||
UnityStudio.SetProgressBarValue = SetProgressBarValue;
|
||||
UnityStudio.SetProgressBarMaximum = SetProgressBarMaximum;
|
||||
UnityStudio.ProgressBarPerformStep = ProgressBarPerformStep;
|
||||
UnityStudio.StatusStripUpdate = StatusStripUpdate;
|
||||
UnityStudio.ProgressBarMaximumAdd = ProgressBarMaximumAdd;
|
||||
Studio.SetProgressBarValue = SetProgressBarValue;
|
||||
Studio.SetProgressBarMaximum = SetProgressBarMaximum;
|
||||
Studio.ProgressBarPerformStep = ProgressBarPerformStep;
|
||||
Studio.StatusStripUpdate = StatusStripUpdate;
|
||||
Studio.ProgressBarMaximumAdd = ProgressBarMaximumAdd;
|
||||
}
|
||||
|
||||
private void timerOpenTK_Tick(object sender, EventArgs e)
|
||||
@@ -1837,13 +1802,23 @@ namespace Unity_Studio
|
||||
|
||||
private void resetForm()
|
||||
{
|
||||
Text = "Unity Studio";
|
||||
Text = "AssetStudio";
|
||||
|
||||
unityFiles.Clear();
|
||||
importFiles.Clear();
|
||||
foreach (var assetsFile in assetsfileList)
|
||||
{
|
||||
assetsFile.assetsFileReader.Dispose();
|
||||
}
|
||||
assetsfileList.Clear();
|
||||
exportableAssets.Clear();
|
||||
visibleAssets.Clear();
|
||||
assetsfileandstream.Clear();
|
||||
foreach (var resourceFileReader in resourceFileReaders)
|
||||
{
|
||||
resourceFileReader.Value.Dispose();
|
||||
}
|
||||
resourceFileReaders.Clear();
|
||||
sharedFileIndex.Clear();
|
||||
productName = "";
|
||||
|
||||
sceneTreeView.Nodes.Clear();
|
||||
|
||||
@@ -1872,7 +1847,7 @@ namespace Unity_Studio
|
||||
|
||||
private void showOriginalFileToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var args = $"/select, {selectasset.sourceFile.bundlePath ?? selectasset.sourceFile.filePath}";
|
||||
var args = $"/select, {selectasset.sourceFile.parentPath ?? selectasset.sourceFile.filePath}";
|
||||
var pfi = new ProcessStartInfo("explorer.exe", args);
|
||||
Process.Start(pfi);
|
||||
}
|
||||
@@ -1894,5 +1869,41 @@ namespace Unity_Studio
|
||||
glControl1.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private void ExportAnimatorwithAnimationClip_Click(object sender, EventArgs e)
|
||||
{
|
||||
AssetPreloadData animator = null;
|
||||
List<AssetPreloadData> animationList = new List<AssetPreloadData>();
|
||||
for (int i = 0; i < assetListView.SelectedIndices.Count; i++)
|
||||
{
|
||||
var index = assetListView.SelectedIndices[i];
|
||||
var asset = (AssetPreloadData)assetListView.Items[index];
|
||||
if (asset.Type2 == 95) //Animator
|
||||
{
|
||||
animator = asset;
|
||||
}
|
||||
else if (asset.Type2 == 74) //AnimationClip
|
||||
{
|
||||
animationList.Add(asset);
|
||||
}
|
||||
}
|
||||
|
||||
if (animator != null)
|
||||
{
|
||||
var saveFolderDialog1 = new OpenFolderDialog();
|
||||
if (saveFolderDialog1.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
var savePath = saveFolderDialog1.Folder;
|
||||
string exportpath = savePath + "\\Animator\\";
|
||||
SetProgressBarValue(0);
|
||||
SetProgressBarMaximum(1);
|
||||
ThreadPool.QueueUserWorkItem(state =>
|
||||
{
|
||||
StatusStripUpdate(ExportAnimator(animator, animationList, exportpath) ? "Successfully exported" : "Nothing exported.");
|
||||
ProgressBarPerformStep();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -150,9 +150,6 @@ The quick brown fox jumps over the lazy dog. 1234567890</value>
|
||||
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>636, 17</value>
|
||||
</metadata>
|
||||
<data name="openFileDialog1.Filter" xml:space="preserve">
|
||||
<value>Unity asset files|*.*|Unity bundle files|*.*|Unity asset files|level*; globalgamemanagers; mainData; CustomAssetBundle-*; CAB-*; BuildPlayer-*; *.assets; *.sharedAssets|Unity bundle files|*.unity3d; *.unity3d.lz4; *.assetbundle; *.bundle; *.bytes</value>
|
||||
</data>
|
||||
<metadata name="saveFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>784, 17</value>
|
||||
</metadata>
|
||||
31
AssetStudio/Classes/Animation.cs
Normal file
31
AssetStudio/Classes/Animation.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
class Animation
|
||||
{
|
||||
public PPtr m_GameObject;
|
||||
public List<PPtr> m_Animations;
|
||||
|
||||
public Animation(AssetPreloadData preloadData)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var reader = preloadData.InitReader();
|
||||
reader.Position = preloadData.Offset;
|
||||
|
||||
m_GameObject = sourceFile.ReadPPtr();
|
||||
var m_Enabled = reader.ReadByte();
|
||||
reader.AlignStream(4);
|
||||
var m_Animation = sourceFile.ReadPPtr();
|
||||
int numAnimations = reader.ReadInt32();
|
||||
m_Animations = new List<PPtr>(numAnimations);
|
||||
for (int i = 0; i < numAnimations; i++)
|
||||
{
|
||||
m_Animations.Add(sourceFile.ReadPPtr());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
763
AssetStudio/Classes/AnimationClip.cs
Normal file
763
AssetStudio/Classes/AnimationClip.cs
Normal file
@@ -0,0 +1,763 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using SharpDX;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class Keyframe<T>
|
||||
{
|
||||
public float time { get; set; }
|
||||
public T value { get; set; }
|
||||
public T inSlope { get; set; }
|
||||
public T outSlope { get; set; }
|
||||
|
||||
public Keyframe(EndianBinaryReader reader, Func<T> readerFunc)
|
||||
{
|
||||
time = reader.ReadSingle();
|
||||
value = readerFunc();
|
||||
inSlope = readerFunc();
|
||||
outSlope = readerFunc();
|
||||
}
|
||||
}
|
||||
|
||||
public class AnimationCurve<T>
|
||||
{
|
||||
public List<Keyframe<T>> m_Curve { get; set; }
|
||||
public int m_PreInfinity { get; set; }
|
||||
public int m_PostInfinity { get; set; }
|
||||
public int m_RotationOrder { get; set; }
|
||||
|
||||
public AnimationCurve(EndianBinaryReader reader, Func<T> readerFunc, int[] version)
|
||||
{
|
||||
int numCurves = reader.ReadInt32();
|
||||
m_Curve = new List<Keyframe<T>>(numCurves);
|
||||
for (int i = 0; i < numCurves; i++)
|
||||
{
|
||||
m_Curve.Add(new Keyframe<T>(reader, readerFunc));
|
||||
}
|
||||
|
||||
m_PreInfinity = reader.ReadInt32();
|
||||
m_PostInfinity = reader.ReadInt32();
|
||||
if (version[0] >= 5)//5.0 and up
|
||||
{
|
||||
m_RotationOrder = reader.ReadInt32();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class QuaternionCurve
|
||||
{
|
||||
public AnimationCurve<Quaternion> curve { get; set; }
|
||||
public string path { get; set; }
|
||||
|
||||
public QuaternionCurve(EndianBinaryReader reader, int[] version)
|
||||
{
|
||||
curve = new AnimationCurve<Quaternion>(reader, reader.ReadQuaternion, version);
|
||||
path = reader.ReadAlignedString();
|
||||
}
|
||||
}
|
||||
|
||||
public class PackedBitVector
|
||||
{
|
||||
public uint m_NumItems { get; set; }
|
||||
public float m_Range { get; set; }
|
||||
public float m_Start { get; set; }
|
||||
public byte[] m_Data { get; set; }
|
||||
public byte m_BitSize { get; set; }
|
||||
|
||||
public PackedBitVector(EndianBinaryReader reader)
|
||||
{
|
||||
m_NumItems = reader.ReadUInt32();
|
||||
m_Range = reader.ReadSingle();
|
||||
m_Start = reader.ReadSingle();
|
||||
|
||||
int numData = reader.ReadInt32();
|
||||
m_Data = reader.ReadBytes(numData);
|
||||
reader.AlignStream(4);
|
||||
|
||||
m_BitSize = reader.ReadByte();
|
||||
reader.AlignStream(4);
|
||||
}
|
||||
}
|
||||
|
||||
public class PackedBitVector2
|
||||
{
|
||||
public uint m_NumItems { get; set; }
|
||||
public byte[] m_Data { get; set; }
|
||||
public byte m_BitSize { get; set; }
|
||||
|
||||
public PackedBitVector2(EndianBinaryReader reader)
|
||||
{
|
||||
m_NumItems = reader.ReadUInt32();
|
||||
|
||||
int numData = reader.ReadInt32();
|
||||
m_Data = reader.ReadBytes(numData);
|
||||
reader.AlignStream(4);
|
||||
|
||||
m_BitSize = reader.ReadByte();
|
||||
reader.AlignStream(4);
|
||||
}
|
||||
}
|
||||
|
||||
public class PackedBitVector3
|
||||
{
|
||||
public uint m_NumItems { get; set; }
|
||||
public byte[] m_Data { get; set; }
|
||||
|
||||
public PackedBitVector3(EndianBinaryReader reader)
|
||||
{
|
||||
m_NumItems = reader.ReadUInt32();
|
||||
|
||||
int numData = reader.ReadInt32();
|
||||
m_Data = reader.ReadBytes(numData);
|
||||
|
||||
reader.AlignStream(4);
|
||||
}
|
||||
}
|
||||
|
||||
public class CompressedAnimationCurve
|
||||
{
|
||||
public string m_Path { get; set; }
|
||||
public PackedBitVector2 m_Times { get; set; }
|
||||
public PackedBitVector3 m_Values { get; set; }
|
||||
public PackedBitVector m_Slopes { get; set; }
|
||||
public int m_PreInfinity { get; set; }
|
||||
public int m_PostInfinity { get; set; }
|
||||
|
||||
public CompressedAnimationCurve(EndianBinaryReader reader)
|
||||
{
|
||||
m_Path = reader.ReadAlignedString();
|
||||
m_Times = new PackedBitVector2(reader);
|
||||
m_Values = new PackedBitVector3(reader);
|
||||
m_Slopes = new PackedBitVector(reader);
|
||||
m_PreInfinity = reader.ReadInt32();
|
||||
m_PostInfinity = reader.ReadInt32();
|
||||
}
|
||||
}
|
||||
|
||||
public class Vector3Curve
|
||||
{
|
||||
public AnimationCurve<Vector3> curve { get; set; }
|
||||
public string path { get; set; }
|
||||
|
||||
public Vector3Curve(EndianBinaryReader reader, int[] version)
|
||||
{
|
||||
curve = new AnimationCurve<Vector3>(reader, reader.ReadVector3, version);
|
||||
path = reader.ReadAlignedString();
|
||||
}
|
||||
}
|
||||
|
||||
public class FloatCurve
|
||||
{
|
||||
public AnimationCurve<float> curve { get; set; }
|
||||
public string attribute { get; set; }
|
||||
public string path { get; set; }
|
||||
public int classID { get; set; }
|
||||
public PPtr script { get; set; }
|
||||
|
||||
|
||||
public FloatCurve(AssetPreloadData preloadData)
|
||||
{
|
||||
var reader = preloadData.sourceFile.assetsFileReader;
|
||||
curve = new AnimationCurve<float>(reader, reader.ReadSingle, preloadData.sourceFile.version);
|
||||
attribute = reader.ReadAlignedString();
|
||||
path = reader.ReadAlignedString();
|
||||
classID = reader.ReadInt32();
|
||||
script = preloadData.sourceFile.ReadPPtr();
|
||||
}
|
||||
}
|
||||
|
||||
public class PPtrKeyframe
|
||||
{
|
||||
public float time { get; set; }
|
||||
public PPtr value { get; set; }
|
||||
|
||||
|
||||
public PPtrKeyframe(AssetPreloadData preloadData)
|
||||
{
|
||||
var reader = preloadData.sourceFile.assetsFileReader;
|
||||
time = reader.ReadSingle();
|
||||
value = preloadData.sourceFile.ReadPPtr();
|
||||
}
|
||||
}
|
||||
|
||||
public class PPtrCurve
|
||||
{
|
||||
public List<PPtrKeyframe> curve { get; set; }
|
||||
public string attribute { get; set; }
|
||||
public string path { get; set; }
|
||||
public int classID { get; set; }
|
||||
public PPtr script { get; set; }
|
||||
|
||||
|
||||
public PPtrCurve(AssetPreloadData preloadData)
|
||||
{
|
||||
var reader = preloadData.sourceFile.assetsFileReader;
|
||||
|
||||
int numCurves = reader.ReadInt32();
|
||||
curve = new List<PPtrKeyframe>(numCurves);
|
||||
for (int i = 0; i < numCurves; i++)
|
||||
{
|
||||
curve.Add(new PPtrKeyframe(preloadData));
|
||||
}
|
||||
|
||||
attribute = reader.ReadAlignedString();
|
||||
path = reader.ReadAlignedString();
|
||||
classID = reader.ReadInt32();
|
||||
script = preloadData.sourceFile.ReadPPtr();
|
||||
}
|
||||
}
|
||||
|
||||
public class AABB
|
||||
{
|
||||
public Vector3 m_Center { get; set; }
|
||||
public Vector3 m_Extend { get; set; }
|
||||
|
||||
public AABB(EndianBinaryReader reader)
|
||||
{
|
||||
m_Center = reader.ReadVector3();
|
||||
m_Extend = reader.ReadVector3();
|
||||
}
|
||||
}
|
||||
|
||||
public class xform
|
||||
{
|
||||
public object t { get; set; }
|
||||
public Quaternion q { get; set; }
|
||||
public object s { get; set; }
|
||||
|
||||
public xform(EndianBinaryReader reader, int[] version)
|
||||
{
|
||||
t = version[0] > 5 || (version[0] == 5 && version[1] >= 4) ? (object)reader.ReadVector3() : (object)reader.ReadVector4();//5.4 and up
|
||||
q = reader.ReadQuaternion();
|
||||
s = version[0] > 5 || (version[0] == 5 && version[1] >= 4) ? (object)reader.ReadVector3() : (object)reader.ReadVector4();//5.4 and up
|
||||
}
|
||||
}
|
||||
|
||||
public class HandPose
|
||||
{
|
||||
public xform m_GrabX { get; set; }
|
||||
public float[] m_DoFArray { get; set; }
|
||||
public float m_Override { get; set; }
|
||||
public float m_CloseOpen { get; set; }
|
||||
public float m_InOut { get; set; }
|
||||
public float m_Grab { get; set; }
|
||||
|
||||
public HandPose(EndianBinaryReader reader, int[] version)
|
||||
{
|
||||
m_GrabX = new xform(reader, version);
|
||||
|
||||
int numDoFs = reader.ReadInt32();
|
||||
m_DoFArray = reader.ReadSingleArray(numDoFs);
|
||||
|
||||
m_Override = reader.ReadSingle();
|
||||
m_CloseOpen = reader.ReadSingle();
|
||||
m_InOut = reader.ReadSingle();
|
||||
m_Grab = reader.ReadSingle();
|
||||
}
|
||||
}
|
||||
|
||||
public class HumanGoal
|
||||
{
|
||||
public xform m_X { get; set; }
|
||||
public float m_WeightT { get; set; }
|
||||
public float m_WeightR { get; set; }
|
||||
public object m_HintT { get; set; }
|
||||
public float m_HintWeightT { get; set; }
|
||||
|
||||
public HumanGoal(EndianBinaryReader reader, int[] version)
|
||||
{
|
||||
m_X = new xform(reader, version);
|
||||
m_WeightT = reader.ReadSingle();
|
||||
m_WeightR = reader.ReadSingle();
|
||||
if (version[0] >= 5)//5.0 and up
|
||||
{
|
||||
m_HintT = version[0] > 5 || (version[0] == 5 && version[1] >= 4) ? (object)reader.ReadVector3() : (object)reader.ReadVector4();//5.4 and up
|
||||
m_HintWeightT = reader.ReadSingle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class HumanPose
|
||||
{
|
||||
public xform m_RootX { get; set; }
|
||||
public object m_LookAtPosition { get; set; }
|
||||
public Vector4 m_LookAtWeight { get; set; }
|
||||
public List<HumanGoal> m_GoalArray { get; set; }
|
||||
public HandPose m_LeftHandPose { get; set; }
|
||||
public HandPose m_RightHandPose { get; set; }
|
||||
public float[] m_DoFArray { get; set; }
|
||||
public object[] m_TDoFArray { get; set; }
|
||||
|
||||
public HumanPose(EndianBinaryReader reader, int[] version)
|
||||
{
|
||||
m_RootX = new xform(reader, version);
|
||||
m_LookAtPosition = version[0] > 5 || (version[0] == 5 && version[1] >= 4) ? (object)reader.ReadVector3() : (object)reader.ReadVector4();//5.4 and up
|
||||
m_LookAtWeight = reader.ReadVector4();
|
||||
|
||||
int numGoals = reader.ReadInt32();
|
||||
m_GoalArray = new List<HumanGoal>(numGoals);
|
||||
for (int i = 0; i < numGoals; i++)
|
||||
{
|
||||
m_GoalArray.Add(new HumanGoal(reader, version));
|
||||
}
|
||||
|
||||
m_LeftHandPose = new HandPose(reader, version);
|
||||
m_RightHandPose = new HandPose(reader, version);
|
||||
|
||||
int numDoFs = reader.ReadInt32();
|
||||
m_DoFArray = reader.ReadSingleArray(numDoFs);
|
||||
|
||||
if (version[0] >= 5)//5.0 and up
|
||||
{
|
||||
int numTDof = reader.ReadInt32();
|
||||
m_TDoFArray = new object[numTDof];
|
||||
for (int i = 0; i < numTDof; i++)
|
||||
{
|
||||
m_TDoFArray[i] = version[0] > 5 || (version[0] == 5 && version[1] >= 4) ? (object)reader.ReadVector3() : (object)reader.ReadVector4();//5.4 and up
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class StreamedClip
|
||||
{
|
||||
public uint[] data { get; set; }
|
||||
public uint curveCount { get; set; }
|
||||
|
||||
public StreamedClip(EndianBinaryReader reader)
|
||||
{
|
||||
int numData = reader.ReadInt32();
|
||||
data = reader.ReadUInt32Array(numData);
|
||||
curveCount = reader.ReadUInt32();
|
||||
}
|
||||
|
||||
public class StreamedCurveKey
|
||||
{
|
||||
public int index { get; set; }
|
||||
public Vector3 tcb { get; set; }
|
||||
public float value { get; set; }
|
||||
public StreamedCurveKey(BinaryReader reader)
|
||||
{
|
||||
index = reader.ReadInt32();
|
||||
tcb = reader.ReadVector3();
|
||||
value = reader.ReadSingle();
|
||||
}
|
||||
}
|
||||
|
||||
public class StreamedFrame
|
||||
{
|
||||
public float time { get; set; }
|
||||
public List<StreamedCurveKey> keyList { get; set; }
|
||||
|
||||
public StreamedFrame(BinaryReader reader)
|
||||
{
|
||||
time = reader.ReadSingle();
|
||||
|
||||
int numKeys = reader.ReadInt32();
|
||||
keyList = new List<StreamedCurveKey>(numKeys);
|
||||
for (int i = 0; i < numKeys; i++)
|
||||
{
|
||||
keyList.Add(new StreamedCurveKey(reader));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<StreamedFrame> ReadData()
|
||||
{
|
||||
List<StreamedFrame> frameList = new List<StreamedFrame>();
|
||||
using (Stream stream = new MemoryStream())
|
||||
{
|
||||
BinaryWriter writer = new BinaryWriter(stream);
|
||||
writer.Write(data);
|
||||
stream.Position = 0;
|
||||
while (stream.Position < stream.Length)
|
||||
{
|
||||
frameList.Add(new StreamedFrame(new BinaryReader(stream)));
|
||||
}
|
||||
}
|
||||
return frameList;
|
||||
}
|
||||
}
|
||||
|
||||
public class DenseClip
|
||||
{
|
||||
public int m_FrameCount { get; set; }
|
||||
public uint m_CurveCount { get; set; }
|
||||
public float m_SampleRate { get; set; }
|
||||
public float m_BeginTime { get; set; }
|
||||
public float[] m_SampleArray { get; set; }
|
||||
|
||||
public DenseClip(EndianBinaryReader reader)
|
||||
{
|
||||
m_FrameCount = reader.ReadInt32();
|
||||
m_CurveCount = reader.ReadUInt32();
|
||||
m_SampleRate = reader.ReadSingle();
|
||||
m_BeginTime = reader.ReadSingle();
|
||||
|
||||
int numSamples = reader.ReadInt32();
|
||||
m_SampleArray = reader.ReadSingleArray(numSamples);
|
||||
}
|
||||
}
|
||||
|
||||
public class ConstantClip
|
||||
{
|
||||
public float[] data { get; set; }
|
||||
|
||||
public ConstantClip(EndianBinaryReader reader)
|
||||
{
|
||||
int numData = reader.ReadInt32();
|
||||
data = reader.ReadSingleArray(numData);
|
||||
}
|
||||
}
|
||||
|
||||
public class ValueConstant
|
||||
{
|
||||
public uint m_ID { get; set; }
|
||||
public uint m_TypeID { get; set; }
|
||||
public uint m_Type { get; set; }
|
||||
public uint m_Index { get; set; }
|
||||
|
||||
public ValueConstant(EndianBinaryReader reader, int[] version)
|
||||
{
|
||||
m_ID = reader.ReadUInt32();
|
||||
if (version[0] < 5 || (version[0] == 5 && version[1] < 5))//5.5 down
|
||||
{
|
||||
m_TypeID = reader.ReadUInt32();
|
||||
}
|
||||
m_Type = reader.ReadUInt32();
|
||||
m_Index = reader.ReadUInt32();
|
||||
}
|
||||
}
|
||||
|
||||
public class ValueArrayConstant
|
||||
{
|
||||
public List<ValueConstant> m_ValueArray { get; set; }
|
||||
|
||||
public ValueArrayConstant(EndianBinaryReader reader, int[] version)
|
||||
{
|
||||
int numVals = reader.ReadInt32();
|
||||
m_ValueArray = new List<ValueConstant>(numVals);
|
||||
for (int i = 0; i < numVals; i++)
|
||||
{
|
||||
m_ValueArray.Add(new ValueConstant(reader, version));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Clip
|
||||
{
|
||||
public StreamedClip m_StreamedClip { get; set; }
|
||||
public DenseClip m_DenseClip { get; set; }
|
||||
public ConstantClip m_ConstantClip { get; set; }
|
||||
public ValueArrayConstant m_Binding { get; set; }
|
||||
|
||||
public Clip(EndianBinaryReader reader, int[] version)
|
||||
{
|
||||
m_StreamedClip = new StreamedClip(reader);
|
||||
m_DenseClip = new DenseClip(reader);
|
||||
m_ConstantClip = new ConstantClip(reader);
|
||||
m_Binding = new ValueArrayConstant(reader, version);
|
||||
}
|
||||
}
|
||||
|
||||
public class ValueDelta
|
||||
{
|
||||
public float m_Start { get; set; }
|
||||
public float m_Stop { get; set; }
|
||||
|
||||
public ValueDelta(EndianBinaryReader reader)
|
||||
{
|
||||
m_Start = reader.ReadSingle();
|
||||
m_Stop = reader.ReadSingle();
|
||||
}
|
||||
}
|
||||
|
||||
public class ClipMuscleConstant
|
||||
{
|
||||
public HumanPose m_DeltaPose { get; set; }
|
||||
public xform m_StartX { get; set; }
|
||||
public xform m_StopX { get; set; }
|
||||
public xform m_LeftFootStartX { get; set; }
|
||||
public xform m_RightFootStartX { get; set; }
|
||||
public xform m_MotionStartX { get; set; }
|
||||
public xform m_MotionStopX { get; set; }
|
||||
public object m_AverageSpeed { get; set; }
|
||||
public Clip m_Clip { get; set; }
|
||||
public float m_StartTime { get; set; }
|
||||
public float m_StopTime { get; set; }
|
||||
public float m_OrientationOffsetY { get; set; }
|
||||
public float m_Level { get; set; }
|
||||
public float m_CycleOffset { get; set; }
|
||||
public float m_AverageAngularSpeed { get; set; }
|
||||
public int[] m_IndexArray { get; set; }
|
||||
public List<ValueDelta> m_ValueArrayDelta { get; set; }
|
||||
public float[] m_ValueArrayReferencePose { get; set; }
|
||||
public bool m_Mirror { get; set; }
|
||||
public bool m_LoopTime { get; set; }
|
||||
public bool m_LoopBlend { get; set; }
|
||||
public bool m_LoopBlendOrientation { get; set; }
|
||||
public bool m_LoopBlendPositionY { get; set; }
|
||||
public bool m_LoopBlendPositionXZ { get; set; }
|
||||
public bool m_StartAtOrigin { get; set; }
|
||||
public bool m_KeepOriginalOrientation { get; set; }
|
||||
public bool m_KeepOriginalPositionY { get; set; }
|
||||
public bool m_KeepOriginalPositionXZ { get; set; }
|
||||
public bool m_HeightFromFeet { get; set; }
|
||||
|
||||
public ClipMuscleConstant(EndianBinaryReader reader, int[] version)
|
||||
{
|
||||
m_DeltaPose = new HumanPose(reader, version);
|
||||
m_StartX = new xform(reader, version);
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 5))//5.5 and up
|
||||
{
|
||||
m_StopX = new xform(reader, version);
|
||||
}
|
||||
m_LeftFootStartX = new xform(reader, version);
|
||||
m_RightFootStartX = new xform(reader, version);
|
||||
if (version[0] < 5)//5.0 down
|
||||
{
|
||||
m_MotionStartX = new xform(reader, version);
|
||||
m_MotionStopX = new xform(reader, version);
|
||||
}
|
||||
m_AverageSpeed = version[0] > 5 || (version[0] == 5 && version[1] >= 4) ? (object)reader.ReadVector3() : (object)reader.ReadVector4();//5.4 and up
|
||||
m_Clip = new Clip(reader, version);
|
||||
m_StartTime = reader.ReadSingle();
|
||||
m_StopTime = reader.ReadSingle();
|
||||
m_OrientationOffsetY = reader.ReadSingle();
|
||||
m_Level = reader.ReadSingle();
|
||||
m_CycleOffset = reader.ReadSingle();
|
||||
m_AverageAngularSpeed = reader.ReadSingle();
|
||||
|
||||
int numIndices = reader.ReadInt32();
|
||||
m_IndexArray = reader.ReadInt32Array(numIndices);
|
||||
|
||||
int numDeltas = reader.ReadInt32();
|
||||
m_ValueArrayDelta = new List<ValueDelta>(numDeltas);
|
||||
for (int i = 0; i < numDeltas; i++)
|
||||
{
|
||||
m_ValueArrayDelta.Add(new ValueDelta(reader));
|
||||
}
|
||||
if (version[0] >= 5)//5.0 and up
|
||||
{
|
||||
m_ValueArrayReferencePose = reader.ReadSingleArray(reader.ReadInt32());
|
||||
}
|
||||
|
||||
m_Mirror = reader.ReadBoolean();
|
||||
m_LoopTime = reader.ReadBoolean();
|
||||
m_LoopBlend = reader.ReadBoolean();
|
||||
m_LoopBlendOrientation = reader.ReadBoolean();
|
||||
m_LoopBlendPositionY = reader.ReadBoolean();
|
||||
m_LoopBlendPositionXZ = reader.ReadBoolean();
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 5))//5.5 and up
|
||||
{
|
||||
m_StartAtOrigin = reader.ReadBoolean();
|
||||
}
|
||||
m_KeepOriginalOrientation = reader.ReadBoolean();
|
||||
m_KeepOriginalPositionY = reader.ReadBoolean();
|
||||
m_KeepOriginalPositionXZ = reader.ReadBoolean();
|
||||
m_HeightFromFeet = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
}
|
||||
}
|
||||
|
||||
public class GenericBinding
|
||||
{
|
||||
public uint path { get; set; }
|
||||
public uint attribute { get; set; }
|
||||
public PPtr script { get; set; }
|
||||
public int typeID { get; set; }
|
||||
public byte customType { get; set; }
|
||||
public byte isPPtrCurve { get; set; }
|
||||
|
||||
public GenericBinding(AssetPreloadData preloadData)
|
||||
{
|
||||
var reader = preloadData.sourceFile.assetsFileReader;
|
||||
var version = preloadData.sourceFile.version;
|
||||
path = reader.ReadUInt32();
|
||||
attribute = reader.ReadUInt32();
|
||||
script = preloadData.sourceFile.ReadPPtr();
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 6)) //5.6 and up
|
||||
{
|
||||
typeID = reader.ReadInt32();
|
||||
}
|
||||
else
|
||||
{
|
||||
typeID = reader.ReadUInt16();
|
||||
}
|
||||
customType = reader.ReadByte();
|
||||
isPPtrCurve = reader.ReadByte();
|
||||
reader.AlignStream(4);
|
||||
}
|
||||
}
|
||||
|
||||
public class AnimationClipBindingConstant
|
||||
{
|
||||
public List<GenericBinding> genericBindings { get; set; }
|
||||
public List<PPtr> pptrCurveMapping { get; set; }
|
||||
|
||||
public AnimationClipBindingConstant(AssetPreloadData preloadData)
|
||||
{
|
||||
var reader = preloadData.sourceFile.assetsFileReader;
|
||||
int numBindings = reader.ReadInt32();
|
||||
genericBindings = new List<GenericBinding>(numBindings);
|
||||
for (int i = 0; i < numBindings; i++)
|
||||
{
|
||||
genericBindings.Add(new GenericBinding(preloadData));
|
||||
}
|
||||
|
||||
int numMappings = reader.ReadInt32();
|
||||
pptrCurveMapping = new List<PPtr>(numMappings);
|
||||
for (int i = 0; i < numMappings; i++)
|
||||
{
|
||||
pptrCurveMapping.Add(preloadData.sourceFile.ReadPPtr());
|
||||
}
|
||||
}
|
||||
|
||||
public GenericBinding FindBinding(int index)
|
||||
{
|
||||
int curves = 0;
|
||||
for (int i = 0; i < genericBindings.Count; i++)
|
||||
{
|
||||
GenericBinding b = genericBindings[i];
|
||||
curves += b.attribute == 2 ? 4 : b.attribute <= 4 ? 3 : 1;
|
||||
if (curves > index)
|
||||
{
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public GenericBinding FindBinding(uint path, uint attribute)
|
||||
{
|
||||
return genericBindings.Find
|
||||
(
|
||||
delegate (GenericBinding b)
|
||||
{
|
||||
return b.path == path && b.attribute == attribute;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public class AnimationClip
|
||||
{
|
||||
public string m_Name { get; set; }
|
||||
public int m_AnimationType { get; set; }
|
||||
public bool m_Legacy { get; set; }
|
||||
public bool m_Compressed { get; set; }
|
||||
public bool m_UseHighQualityCurve { get; set; }
|
||||
public List<QuaternionCurve> m_RotationCurves { get; set; }
|
||||
public List<CompressedAnimationCurve> m_CompressedRotationCurves { get; set; }
|
||||
public List<Vector3Curve> m_EulerCurves { get; set; }
|
||||
public List<Vector3Curve> m_PositionCurves { get; set; }
|
||||
public List<Vector3Curve> m_ScaleCurves { get; set; }
|
||||
public List<FloatCurve> m_FloatCurves { get; set; }
|
||||
public List<PPtrCurve> m_PPtrCurves { get; set; }
|
||||
public float m_SampleRate { get; set; }
|
||||
public int m_WrapMode { get; set; }
|
||||
public AABB m_Bounds { get; set; }
|
||||
public uint m_MuscleClipSize { get; set; }
|
||||
public ClipMuscleConstant m_MuscleClip { get; set; }
|
||||
public AnimationClipBindingConstant m_ClipBindingConstant { get; set; }
|
||||
//public List<AnimationEvent> m_Events { get; set; }
|
||||
|
||||
|
||||
public AnimationClip(AssetPreloadData preloadData)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var version = sourceFile.version;
|
||||
var reader = preloadData.InitReader();
|
||||
reader.Position = preloadData.Offset;
|
||||
|
||||
m_Name = reader.ReadAlignedString();
|
||||
if (version[0] >= 5)//5.0 and up
|
||||
{
|
||||
m_Legacy = reader.ReadBoolean();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_AnimationType = reader.ReadInt32();
|
||||
}
|
||||
m_Compressed = reader.ReadBoolean();
|
||||
m_UseHighQualityCurve = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
if (m_Compressed)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
int numRCurves = reader.ReadInt32();
|
||||
m_RotationCurves = new List<QuaternionCurve>(numRCurves);
|
||||
for (int i = 0; i < numRCurves; i++)
|
||||
{
|
||||
m_RotationCurves.Add(new QuaternionCurve(reader, version));
|
||||
}
|
||||
|
||||
int numCRCurves = reader.ReadInt32();
|
||||
m_CompressedRotationCurves = new List<CompressedAnimationCurve>(numCRCurves);
|
||||
for (int i = 0; i < numCRCurves; i++)
|
||||
{
|
||||
m_CompressedRotationCurves.Add(new CompressedAnimationCurve(reader));
|
||||
}
|
||||
|
||||
if (version[0] >= 5)//5.0 and up
|
||||
{
|
||||
int numEulerCurves = reader.ReadInt32();
|
||||
m_EulerCurves = new List<Vector3Curve>(numEulerCurves);
|
||||
for (int i = 0; i < numEulerCurves; i++)
|
||||
{
|
||||
m_EulerCurves.Add(new Vector3Curve(reader, version));
|
||||
}
|
||||
}
|
||||
|
||||
int numPCurves = reader.ReadInt32();
|
||||
m_PositionCurves = new List<Vector3Curve>(numPCurves);
|
||||
for (int i = 0; i < numPCurves; i++)
|
||||
{
|
||||
m_PositionCurves.Add(new Vector3Curve(reader, version));
|
||||
}
|
||||
|
||||
int numSCurves = reader.ReadInt32();
|
||||
m_ScaleCurves = new List<Vector3Curve>(numSCurves);
|
||||
for (int i = 0; i < numSCurves; i++)
|
||||
{
|
||||
m_ScaleCurves.Add(new Vector3Curve(reader, version));
|
||||
}
|
||||
|
||||
int numFCurves = reader.ReadInt32();
|
||||
m_FloatCurves = new List<FloatCurve>(numFCurves);
|
||||
for (int i = 0; i < numFCurves; i++)
|
||||
{
|
||||
m_FloatCurves.Add(new FloatCurve(preloadData));
|
||||
}
|
||||
|
||||
int numPtrCurves = reader.ReadInt32();
|
||||
m_PPtrCurves = new List<PPtrCurve>(numPtrCurves);
|
||||
for (int i = 0; i < numPtrCurves; i++)
|
||||
{
|
||||
m_PPtrCurves.Add(new PPtrCurve(preloadData));
|
||||
}
|
||||
|
||||
m_SampleRate = reader.ReadSingle();
|
||||
m_WrapMode = reader.ReadInt32();
|
||||
m_Bounds = new AABB(reader);
|
||||
m_MuscleClipSize = reader.ReadUInt32();
|
||||
m_MuscleClip = new ClipMuscleConstant(reader, version);
|
||||
m_ClipBindingConstant = new AnimationClipBindingConstant(preloadData);
|
||||
|
||||
/*int numEvents = reader.ReadInt32();
|
||||
m_Events = new List<AnimationEvent>(numEvents);
|
||||
for (int i = 0; i < numEvents; i++)
|
||||
{
|
||||
m_Events.Add(new AnimationEvent(stream, file.Version[0] - '0'));
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
27
AssetStudio/Classes/Animator.cs
Normal file
27
AssetStudio/Classes/Animator.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
class Animator
|
||||
{
|
||||
public PPtr m_GameObject;
|
||||
public PPtr m_Avatar;
|
||||
public PPtr m_Controller;
|
||||
|
||||
public Animator(AssetPreloadData preloadData)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var reader = preloadData.InitReader();
|
||||
reader.Position = preloadData.Offset;
|
||||
|
||||
m_GameObject = sourceFile.ReadPPtr();
|
||||
var m_Enabled = reader.ReadByte();
|
||||
reader.AlignStream(4);
|
||||
m_Avatar = sourceFile.ReadPPtr();
|
||||
m_Controller = sourceFile.ReadPPtr();
|
||||
}
|
||||
}
|
||||
}
|
||||
560
AssetStudio/Classes/AnimatorController.cs
Normal file
560
AssetStudio/Classes/AnimatorController.cs
Normal file
@@ -0,0 +1,560 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using SharpDX;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class HumanPoseMask
|
||||
{
|
||||
public uint word0 { get; set; }
|
||||
public uint word1 { get; set; }
|
||||
public uint word2 { get; set; }
|
||||
|
||||
public HumanPoseMask(EndianBinaryReader reader, int[] version)
|
||||
{
|
||||
word0 = reader.ReadUInt32();
|
||||
word1 = reader.ReadUInt32();
|
||||
if (version[0] >= 5) //5.0 and up
|
||||
{
|
||||
word2 = reader.ReadUInt32();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SkeletonMaskElement
|
||||
{
|
||||
public uint m_PathHash { get; set; }
|
||||
public float m_Weight { get; set; }
|
||||
|
||||
public SkeletonMaskElement(EndianBinaryReader reader)
|
||||
{
|
||||
m_PathHash = reader.ReadUInt32();
|
||||
m_Weight = reader.ReadSingle();
|
||||
}
|
||||
}
|
||||
|
||||
public class SkeletonMask
|
||||
{
|
||||
public SkeletonMaskElement[] m_Data { get; set; }
|
||||
|
||||
public SkeletonMask(EndianBinaryReader reader)
|
||||
{
|
||||
int numElements = reader.ReadInt32();
|
||||
m_Data = new SkeletonMaskElement[numElements];
|
||||
for (int i = 0; i < numElements; i++)
|
||||
{
|
||||
m_Data[i] = new SkeletonMaskElement(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class LayerConstant
|
||||
{
|
||||
public uint m_StateMachineIndex { get; set; }
|
||||
public uint m_StateMachineMotionSetIndex { get; set; }
|
||||
public HumanPoseMask m_BodyMask { get; set; }
|
||||
public SkeletonMask m_SkeletonMask { get; set; }
|
||||
public uint m_Binding { get; set; }
|
||||
public int m_LayerBlendingMode { get; set; }
|
||||
public float m_DefaultWeight { get; set; }
|
||||
public bool m_IKPass { get; set; }
|
||||
public bool m_SyncedLayerAffectsTiming { get; set; }
|
||||
|
||||
public LayerConstant(EndianBinaryReader reader, int[] version)
|
||||
{
|
||||
m_StateMachineIndex = reader.ReadUInt32();
|
||||
m_StateMachineMotionSetIndex = reader.ReadUInt32();
|
||||
m_BodyMask = new HumanPoseMask(reader, version);
|
||||
m_SkeletonMask = new SkeletonMask(reader);
|
||||
m_Binding = reader.ReadUInt32();
|
||||
m_LayerBlendingMode = reader.ReadInt32();
|
||||
m_DefaultWeight = reader.ReadSingle();
|
||||
m_IKPass = reader.ReadBoolean();
|
||||
m_SyncedLayerAffectsTiming = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
}
|
||||
}
|
||||
|
||||
public class ConditionConstant
|
||||
{
|
||||
public uint m_ConditionMode { get; set; }
|
||||
public uint m_EventID { get; set; }
|
||||
public float m_EventThreshold { get; set; }
|
||||
public float m_ExitTime { get; set; }
|
||||
|
||||
public ConditionConstant(EndianBinaryReader reader)
|
||||
{
|
||||
m_ConditionMode = reader.ReadUInt32();
|
||||
m_EventID = reader.ReadUInt32();
|
||||
m_EventThreshold = reader.ReadSingle();
|
||||
m_ExitTime = reader.ReadSingle();
|
||||
}
|
||||
}
|
||||
|
||||
public class TransitionConstant
|
||||
{
|
||||
public ConditionConstant[] m_ConditionConstantArray { get; set; }
|
||||
public uint m_DestinationState { get; set; }
|
||||
public uint m_FullPathID { get; set; }
|
||||
public uint m_ID { get; set; }
|
||||
public uint m_UserID { get; set; }
|
||||
public float m_TransitionDuration { get; set; }
|
||||
public float m_TransitionOffset { get; set; }
|
||||
public float m_ExitTime { get; set; }
|
||||
public bool m_HasExitTime { get; set; }
|
||||
public bool m_HasFixedDuration { get; set; }
|
||||
public int m_InterruptionSource { get; set; }
|
||||
public bool m_OrderedInterruption { get; set; }
|
||||
public bool m_Atomic { get; set; }
|
||||
public bool m_CanTransitionToSelf { get; set; }
|
||||
|
||||
public TransitionConstant(EndianBinaryReader reader, int[] version)
|
||||
{
|
||||
int numConditions = reader.ReadInt32();
|
||||
m_ConditionConstantArray = new ConditionConstant[numConditions];
|
||||
for (int i = 0; i < numConditions; i++)
|
||||
{
|
||||
m_ConditionConstantArray[i] = new ConditionConstant(reader);
|
||||
}
|
||||
|
||||
m_DestinationState = reader.ReadUInt32();
|
||||
if (version[0] >= 5) //5.0 and up
|
||||
{
|
||||
m_FullPathID = reader.ReadUInt32();
|
||||
}
|
||||
|
||||
m_ID = reader.ReadUInt32();
|
||||
m_UserID = reader.ReadUInt32();
|
||||
m_TransitionDuration = reader.ReadSingle();
|
||||
m_TransitionOffset = reader.ReadSingle();
|
||||
if (version[0] >= 5) //5.0 and up
|
||||
{
|
||||
m_ExitTime = reader.ReadSingle();
|
||||
m_HasExitTime = reader.ReadBoolean();
|
||||
m_HasFixedDuration = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
m_InterruptionSource = reader.ReadInt32();
|
||||
m_OrderedInterruption = reader.ReadBoolean();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Atomic = reader.ReadBoolean();
|
||||
}
|
||||
|
||||
m_CanTransitionToSelf = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
}
|
||||
}
|
||||
|
||||
public class LeafInfoConstant
|
||||
{
|
||||
public uint[] m_IDArray { get; set; }
|
||||
public uint m_IndexOffset { get; set; }
|
||||
|
||||
public LeafInfoConstant(EndianBinaryReader reader)
|
||||
{
|
||||
m_IDArray = reader.ReadUInt32Array(reader.ReadInt32());
|
||||
m_IndexOffset = reader.ReadUInt32();
|
||||
}
|
||||
}
|
||||
|
||||
public class MotionNeighborList
|
||||
{
|
||||
public uint[] m_NeighborArray { get; set; }
|
||||
|
||||
public MotionNeighborList(EndianBinaryReader reader)
|
||||
{
|
||||
m_NeighborArray = reader.ReadUInt32Array(reader.ReadInt32());
|
||||
}
|
||||
}
|
||||
|
||||
public class Blend2dDataConstant
|
||||
{
|
||||
public Vector2[] m_ChildPositionArray { get; set; }
|
||||
public float[] m_ChildMagnitudeArray { get; set; }
|
||||
public Vector2[] m_ChildPairVectorArray { get; set; }
|
||||
public float[] m_ChildPairAvgMagInvArray { get; set; }
|
||||
public MotionNeighborList[] m_ChildNeighborListArray { get; set; }
|
||||
|
||||
public Blend2dDataConstant(EndianBinaryReader reader)
|
||||
{
|
||||
m_ChildPositionArray = reader.ReadVector2Array(reader.ReadInt32());
|
||||
m_ChildMagnitudeArray = reader.ReadSingleArray(reader.ReadInt32());
|
||||
m_ChildPairVectorArray = reader.ReadVector2Array(reader.ReadInt32());
|
||||
m_ChildPairAvgMagInvArray = reader.ReadSingleArray(reader.ReadInt32());
|
||||
|
||||
int numNeighbours = reader.ReadInt32();
|
||||
m_ChildNeighborListArray = new MotionNeighborList[numNeighbours];
|
||||
for (int i = 0; i < numNeighbours; i++)
|
||||
{
|
||||
m_ChildNeighborListArray[i] = new MotionNeighborList(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Blend1dDataConstant // wrong labeled
|
||||
{
|
||||
public float[] m_ChildThresholdArray { get; set; }
|
||||
|
||||
public Blend1dDataConstant(EndianBinaryReader reader)
|
||||
{
|
||||
m_ChildThresholdArray = reader.ReadSingleArray(reader.ReadInt32());
|
||||
}
|
||||
}
|
||||
|
||||
public class BlendDirectDataConstant
|
||||
{
|
||||
public uint[] m_ChildBlendEventIDArray { get; set; }
|
||||
public bool m_NormalizedBlendValues { get; set; }
|
||||
|
||||
public BlendDirectDataConstant(EndianBinaryReader reader)
|
||||
{
|
||||
m_ChildBlendEventIDArray = reader.ReadUInt32Array(reader.ReadInt32());
|
||||
m_NormalizedBlendValues = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
}
|
||||
}
|
||||
|
||||
public class BlendTreeNodeConstant
|
||||
{
|
||||
public uint m_BlendType { get; set; }
|
||||
public uint m_BlendEventID { get; set; }
|
||||
public uint m_BlendEventYID { get; set; }
|
||||
public uint[] m_ChildIndices { get; set; }
|
||||
public Blend1dDataConstant m_Blend1dData { get; set; }
|
||||
public Blend2dDataConstant m_Blend2dData { get; set; }
|
||||
public BlendDirectDataConstant m_BlendDirectData { get; set; }
|
||||
public uint m_ClipID { get; set; }
|
||||
public uint m_ClipIndex { get; set; }
|
||||
public float m_Duration { get; set; }
|
||||
public float m_CycleOffset { get; set; }
|
||||
public bool m_Mirror { get; set; }
|
||||
|
||||
public BlendTreeNodeConstant(EndianBinaryReader reader, int[] version)
|
||||
{
|
||||
m_BlendType = reader.ReadUInt32();
|
||||
m_BlendEventID = reader.ReadUInt32();
|
||||
m_BlendEventYID = reader.ReadUInt32();
|
||||
m_ChildIndices = reader.ReadUInt32Array(reader.ReadInt32());
|
||||
m_Blend1dData = new Blend1dDataConstant(reader);
|
||||
m_Blend2dData = new Blend2dDataConstant(reader);
|
||||
if (version[0] >= 5) //5.0 and up
|
||||
{
|
||||
m_BlendDirectData = new BlendDirectDataConstant(reader);
|
||||
}
|
||||
|
||||
m_ClipID = reader.ReadUInt32();
|
||||
if (version[0] < 5) //5.0 down
|
||||
{
|
||||
m_ClipIndex = reader.ReadUInt32();
|
||||
}
|
||||
|
||||
m_Duration = reader.ReadSingle();
|
||||
m_CycleOffset = reader.ReadSingle();
|
||||
m_Mirror = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
}
|
||||
}
|
||||
|
||||
public class BlendTreeConstant
|
||||
{
|
||||
public BlendTreeNodeConstant[] m_NodeArray { get; set; }
|
||||
|
||||
public BlendTreeConstant(EndianBinaryReader reader, int[] version)
|
||||
{
|
||||
int numNodes = reader.ReadInt32();
|
||||
m_NodeArray = new BlendTreeNodeConstant[numNodes];
|
||||
for (int i = 0; i < numNodes; i++)
|
||||
{
|
||||
m_NodeArray[i] = new BlendTreeNodeConstant(reader, version);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class StateConstant
|
||||
{
|
||||
public TransitionConstant[] m_TransitionConstantArray { get; set; }
|
||||
public int[] m_BlendTreeConstantIndexArray { get; set; }
|
||||
public LeafInfoConstant[] m_LeafInfoArray { get; set; }
|
||||
public BlendTreeConstant[] m_BlendTreeConstantArray { get; set; }
|
||||
public uint m_NameID { get; set; }
|
||||
public uint m_PathID { get; set; }
|
||||
public uint m_FullPathID { get; set; }
|
||||
public uint m_TagID { get; set; }
|
||||
public uint m_SpeedParamID { get; set; }
|
||||
public uint m_MirrorParamID { get; set; }
|
||||
public uint m_CycleOffsetParamID { get; set; }
|
||||
public float m_Speed { get; set; }
|
||||
public float m_CycleOffset { get; set; }
|
||||
public bool m_IKOnFeet { get; set; }
|
||||
public bool m_WriteDefaultValues { get; set; }
|
||||
public bool m_Loop { get; set; }
|
||||
public bool m_Mirror { get; set; }
|
||||
|
||||
public StateConstant(EndianBinaryReader reader, int[] version)
|
||||
{
|
||||
int numTransistions = reader.ReadInt32();
|
||||
m_TransitionConstantArray = new TransitionConstant[numTransistions];
|
||||
for (int i = 0; i < numTransistions; i++)
|
||||
{
|
||||
m_TransitionConstantArray[i] = new TransitionConstant(reader, version);
|
||||
}
|
||||
|
||||
int numBlendIndices = reader.ReadInt32();
|
||||
m_BlendTreeConstantIndexArray = new int[numBlendIndices];
|
||||
for (int i = 0; i < numBlendIndices; i++)
|
||||
{
|
||||
m_BlendTreeConstantIndexArray[i] = reader.ReadInt32();
|
||||
}
|
||||
|
||||
if (version[0] < 5) //5.0 down
|
||||
{
|
||||
int numInfos = reader.ReadInt32();
|
||||
m_LeafInfoArray = new LeafInfoConstant[numInfos];
|
||||
for (int i = 0; i < numInfos; i++)
|
||||
{
|
||||
m_LeafInfoArray[i] = new LeafInfoConstant(reader);
|
||||
}
|
||||
}
|
||||
|
||||
int numBlends = reader.ReadInt32();
|
||||
m_BlendTreeConstantArray = new BlendTreeConstant[numBlends];
|
||||
for (int i = 0; i < numBlends; i++)
|
||||
{
|
||||
m_BlendTreeConstantArray[i] = new BlendTreeConstant(reader, version);
|
||||
}
|
||||
|
||||
m_NameID = reader.ReadUInt32();
|
||||
m_PathID = reader.ReadUInt32();
|
||||
if (version[0] >= 5) //5.0 and up
|
||||
{
|
||||
m_FullPathID = reader.ReadUInt32();
|
||||
}
|
||||
|
||||
m_TagID = reader.ReadUInt32();
|
||||
if (version[0] >= 5) //5.0 and up
|
||||
{
|
||||
m_SpeedParamID = reader.ReadUInt32();
|
||||
m_MirrorParamID = reader.ReadUInt32();
|
||||
m_CycleOffsetParamID = reader.ReadUInt32();
|
||||
}
|
||||
|
||||
if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 2)) //2017.2 and up
|
||||
{
|
||||
var m_TimeParamID = reader.ReadUInt32();
|
||||
}
|
||||
|
||||
m_Speed = reader.ReadSingle();
|
||||
m_CycleOffset = reader.ReadSingle();
|
||||
m_IKOnFeet = reader.ReadBoolean();
|
||||
if (version[0] >= 5) //5.0 and up
|
||||
{
|
||||
m_WriteDefaultValues = reader.ReadBoolean();
|
||||
}
|
||||
|
||||
m_Loop = reader.ReadBoolean();
|
||||
m_Mirror = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
}
|
||||
}
|
||||
|
||||
public class SelectorTransitionConstant
|
||||
{
|
||||
public uint m_Destination { get; set; }
|
||||
public ConditionConstant[] m_ConditionConstantArray { get; set; }
|
||||
|
||||
public SelectorTransitionConstant(EndianBinaryReader reader)
|
||||
{
|
||||
m_Destination = reader.ReadUInt32();
|
||||
|
||||
int numConditions = reader.ReadInt32();
|
||||
m_ConditionConstantArray = new ConditionConstant[numConditions];
|
||||
for (int i = 0; i < numConditions; i++)
|
||||
{
|
||||
m_ConditionConstantArray[i] = new ConditionConstant(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SelectorStateConstant
|
||||
{
|
||||
public SelectorTransitionConstant[] m_TransitionConstantArray { get; set; }
|
||||
public uint m_FullPathID { get; set; }
|
||||
public bool m_isEntry { get; set; }
|
||||
|
||||
public SelectorStateConstant(EndianBinaryReader reader)
|
||||
{
|
||||
int numTransitions = reader.ReadInt32();
|
||||
m_TransitionConstantArray = new SelectorTransitionConstant[numTransitions];
|
||||
for (int i = 0; i < numTransitions; i++)
|
||||
{
|
||||
m_TransitionConstantArray[i] = new SelectorTransitionConstant(reader);
|
||||
}
|
||||
|
||||
m_FullPathID = reader.ReadUInt32();
|
||||
m_isEntry = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
}
|
||||
}
|
||||
|
||||
public class StateMachineConstant
|
||||
{
|
||||
public StateConstant[] m_StateConstantArray { get; set; }
|
||||
public TransitionConstant[] m_AnyStateTransitionConstantArray { get; set; }
|
||||
public SelectorStateConstant[] m_SelectorStateConstantArray { get; set; }
|
||||
public uint m_DefaultState { get; set; }
|
||||
public uint m_MotionSetCount { get; set; }
|
||||
|
||||
public StateMachineConstant(EndianBinaryReader reader, int[] version)
|
||||
{
|
||||
int numStates = reader.ReadInt32();
|
||||
m_StateConstantArray = new StateConstant[numStates];
|
||||
for (int i = 0; i < numStates; i++)
|
||||
{
|
||||
m_StateConstantArray[i] = new StateConstant(reader, version);
|
||||
}
|
||||
|
||||
int numAnyStates = reader.ReadInt32();
|
||||
m_AnyStateTransitionConstantArray = new TransitionConstant[numAnyStates];
|
||||
for (int i = 0; i < numAnyStates; i++)
|
||||
{
|
||||
m_AnyStateTransitionConstantArray[i] = new TransitionConstant(reader, version);
|
||||
}
|
||||
|
||||
if (version[0] >= 5) //5.0 and up
|
||||
{
|
||||
int numSelectors = reader.ReadInt32();
|
||||
m_SelectorStateConstantArray = new SelectorStateConstant[numSelectors];
|
||||
for (int i = 0; i < numSelectors; i++)
|
||||
{
|
||||
m_SelectorStateConstantArray[i] = new SelectorStateConstant(reader);
|
||||
}
|
||||
}
|
||||
|
||||
m_DefaultState = reader.ReadUInt32();
|
||||
m_MotionSetCount = reader.ReadUInt32();
|
||||
}
|
||||
}
|
||||
|
||||
public class ValueArray
|
||||
{
|
||||
public bool[] m_BoolValues { get; set; }
|
||||
public int[] m_IntValues { get; set; }
|
||||
public float[] m_FloatValues { get; set; }
|
||||
public object[] m_PositionValues { get; set; }
|
||||
public Vector4[] m_QuaternionValues { get; set; }
|
||||
public object[] m_ScaleValues { get; set; }
|
||||
|
||||
public ValueArray(EndianBinaryReader reader, int[] version)
|
||||
{
|
||||
if (version[0] < 5 || (version[0] == 5 && version[1] < 5)) //5.5 down
|
||||
{
|
||||
int numBools = reader.ReadInt32();
|
||||
m_BoolValues = new bool[numBools];
|
||||
for (int i = 0; i < numBools; i++)
|
||||
{
|
||||
m_BoolValues[i] = reader.ReadBoolean();
|
||||
}
|
||||
|
||||
reader.AlignStream(4);
|
||||
|
||||
m_IntValues = reader.ReadInt32Array(reader.ReadInt32());
|
||||
m_FloatValues = reader.ReadSingleArray(reader.ReadInt32());
|
||||
}
|
||||
|
||||
int numPosValues = reader.ReadInt32();
|
||||
m_PositionValues = new object[numPosValues];
|
||||
for (int i = 0; i < numPosValues; i++)
|
||||
{
|
||||
m_PositionValues[i] = version[0] > 5 || (version[0] == 5 && version[1] >= 4) ? (object)reader.ReadVector3() : (object)reader.ReadVector4(); //5.4 and up
|
||||
}
|
||||
|
||||
m_QuaternionValues = reader.ReadVector4Array(reader.ReadInt32());
|
||||
|
||||
int numScaleValues = reader.ReadInt32();
|
||||
m_ScaleValues = new object[numScaleValues];
|
||||
for (int i = 0; i < numScaleValues; i++)
|
||||
{
|
||||
m_ScaleValues[i] = version[0] > 5 || (version[0] == 5 && version[1] >= 4) ? (object)reader.ReadVector3() : (object)reader.ReadVector4(); //5.4 adn up
|
||||
}
|
||||
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 5)) //5.5 and up
|
||||
{
|
||||
m_FloatValues = reader.ReadSingleArray(reader.ReadInt32());
|
||||
m_IntValues = reader.ReadInt32Array(reader.ReadInt32());
|
||||
|
||||
int numBools = reader.ReadInt32();
|
||||
m_BoolValues = new bool[numBools];
|
||||
for (int i = 0; i < numBools; i++)
|
||||
{
|
||||
m_BoolValues[i] = reader.ReadBoolean();
|
||||
}
|
||||
|
||||
reader.AlignStream(4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ControllerConstant
|
||||
{
|
||||
public LayerConstant[] m_LayerArray { get; set; }
|
||||
public StateMachineConstant[] m_StateMachineArray { get; set; }
|
||||
public ValueArrayConstant m_Values { get; set; }
|
||||
public ValueArray m_DefaultValues { get; set; }
|
||||
|
||||
public ControllerConstant(EndianBinaryReader reader, int[] version)
|
||||
{
|
||||
int numLayers = reader.ReadInt32();
|
||||
m_LayerArray = new LayerConstant[numLayers];
|
||||
for (int i = 0; i < numLayers; i++)
|
||||
{
|
||||
m_LayerArray[i] = new LayerConstant(reader, version);
|
||||
}
|
||||
|
||||
int numStates = reader.ReadInt32();
|
||||
m_StateMachineArray = new StateMachineConstant[numStates];
|
||||
for (int i = 0; i < numStates; i++)
|
||||
{
|
||||
m_StateMachineArray[i] = new StateMachineConstant(reader, version);
|
||||
}
|
||||
|
||||
m_Values = new ValueArrayConstant(reader, version);
|
||||
m_DefaultValues = new ValueArray(reader, version);
|
||||
}
|
||||
}
|
||||
|
||||
public class AnimatorController
|
||||
{
|
||||
public string m_Name;
|
||||
public PPtr[] m_AnimationClips;
|
||||
|
||||
public AnimatorController(AssetPreloadData preloadData)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var version = preloadData.sourceFile.version;
|
||||
var reader = preloadData.InitReader();
|
||||
reader.Position = preloadData.Offset;
|
||||
|
||||
m_Name = reader.ReadAlignedString();
|
||||
var m_ControllerSize = reader.ReadUInt32();
|
||||
var m_Controller = new ControllerConstant(reader, version);
|
||||
|
||||
int tosSize = reader.ReadInt32();
|
||||
var m_TOS = new List<KeyValuePair<uint, string>>(tosSize);
|
||||
for (int i = 0; i < tosSize; i++)
|
||||
{
|
||||
m_TOS.Add(new KeyValuePair<uint, string>(reader.ReadUInt32(), reader.ReadAlignedString()));
|
||||
}
|
||||
|
||||
int numClips = reader.ReadInt32();
|
||||
m_AnimationClips = new PPtr[numClips];
|
||||
for (int i = 0; i < numClips; i++)
|
||||
{
|
||||
m_AnimationClips[i] = sourceFile.ReadPPtr();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
33
AssetStudio/Classes/AnimatorOverrideController.cs
Normal file
33
AssetStudio/Classes/AnimatorOverrideController.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
class AnimatorOverrideController
|
||||
{
|
||||
public string m_Name;
|
||||
public PPtr m_Controller;
|
||||
public PPtr[][] m_Clips;
|
||||
|
||||
public AnimatorOverrideController(AssetPreloadData preloadData)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var reader = preloadData.InitReader();
|
||||
reader.Position = preloadData.Offset;
|
||||
|
||||
m_Name = reader.ReadAlignedString();
|
||||
m_Controller = sourceFile.ReadPPtr();
|
||||
|
||||
int numOverrides = reader.ReadInt32();
|
||||
m_Clips = new PPtr[numOverrides][];
|
||||
for (int i = 0; i < numOverrides; i++)
|
||||
{
|
||||
m_Clips[i] = new PPtr[2];
|
||||
m_Clips[i][0] = sourceFile.ReadPPtr();
|
||||
m_Clips[i][1] = sourceFile.ReadPPtr();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Unity_Studio
|
||||
namespace AssetStudio
|
||||
{
|
||||
|
||||
class AssetBundle
|
||||
@@ -27,23 +27,22 @@ namespace Unity_Studio
|
||||
public AssetBundle(AssetPreloadData preloadData)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var a_Stream = preloadData.sourceFile.a_Stream;
|
||||
a_Stream.Position = preloadData.Offset;
|
||||
var reader = preloadData.InitReader();
|
||||
|
||||
var m_Name = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
var size = a_Stream.ReadInt32();
|
||||
var m_Name = reader.ReadAlignedString();
|
||||
var size = reader.ReadInt32();
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
sourceFile.ReadPPtr();
|
||||
}
|
||||
size = a_Stream.ReadInt32();
|
||||
size = reader.ReadInt32();
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
var temp = new ContainerData();
|
||||
temp.first = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
temp.first = reader.ReadAlignedString();
|
||||
temp.second = new AssetInfo();
|
||||
temp.second.preloadIndex = a_Stream.ReadInt32();
|
||||
temp.second.preloadSize = a_Stream.ReadInt32();
|
||||
temp.second.preloadIndex = reader.ReadInt32();
|
||||
temp.second.preloadSize = reader.ReadInt32();
|
||||
temp.second.asset = sourceFile.ReadPPtr();
|
||||
m_Container.Add(temp);
|
||||
}
|
||||
@@ -5,7 +5,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Unity_Studio
|
||||
namespace AssetStudio
|
||||
{
|
||||
class AudioClip
|
||||
{
|
||||
@@ -15,7 +15,7 @@ namespace Unity_Studio
|
||||
public bool m_3D;
|
||||
public bool m_UseHardware;
|
||||
|
||||
//Unity 5
|
||||
//version 5
|
||||
public int m_LoadType;
|
||||
public int m_Channels;
|
||||
public int m_Frequency;
|
||||
@@ -38,95 +38,105 @@ namespace Unity_Studio
|
||||
public AudioClip(AssetPreloadData preloadData, bool readSwitch)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var a_Stream = preloadData.sourceFile.a_Stream;
|
||||
a_Stream.Position = preloadData.Offset;
|
||||
var reader = preloadData.InitReader();
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
{
|
||||
uint m_ObjectHideFlags = a_Stream.ReadUInt32();
|
||||
uint m_ObjectHideFlags = reader.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
m_Name = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
m_Name = reader.ReadAlignedString();
|
||||
version5 = sourceFile.version[0] >= 5;
|
||||
if (sourceFile.version[0] < 5)
|
||||
{
|
||||
|
||||
m_Format = a_Stream.ReadInt32(); //channels?
|
||||
m_Type = (AudioType)a_Stream.ReadInt32();
|
||||
m_3D = a_Stream.ReadBoolean();
|
||||
m_UseHardware = a_Stream.ReadBoolean();
|
||||
a_Stream.Position += 2; //4 byte alignment
|
||||
m_Format = reader.ReadInt32(); //channels?
|
||||
m_Type = (AudioType)reader.ReadInt32();
|
||||
m_3D = reader.ReadBoolean();
|
||||
m_UseHardware = reader.ReadBoolean();
|
||||
reader.Position += 2; //4 byte alignment
|
||||
|
||||
if (sourceFile.version[0] >= 4 || (sourceFile.version[0] == 3 && sourceFile.version[1] >= 2)) //3.2.0 to 5
|
||||
{
|
||||
int m_Stream = a_Stream.ReadInt32();
|
||||
m_Size = a_Stream.ReadInt32();
|
||||
int m_Stream = reader.ReadInt32();
|
||||
m_Size = reader.ReadInt32();
|
||||
var tsize = m_Size % 4 != 0 ? m_Size + 4 - m_Size % 4 : m_Size;
|
||||
//TODO: Need more test
|
||||
if (preloadData.Size + preloadData.Offset - a_Stream.Position != tsize)
|
||||
if (preloadData.Size + preloadData.Offset - reader.Position != tsize)
|
||||
{
|
||||
m_Offset = a_Stream.ReadInt32();
|
||||
m_Offset = reader.ReadInt32();
|
||||
m_Source = sourceFile.filePath + ".resS";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Size = a_Stream.ReadInt32();
|
||||
m_Size = reader.ReadInt32();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_LoadType = a_Stream.ReadInt32(); //Decompress on load, Compressed in memory, Streaming
|
||||
m_Channels = a_Stream.ReadInt32();
|
||||
m_Frequency = a_Stream.ReadInt32();
|
||||
m_BitsPerSample = a_Stream.ReadInt32();
|
||||
m_Length = a_Stream.ReadSingle();
|
||||
m_IsTrackerFormat = a_Stream.ReadBoolean();
|
||||
a_Stream.Position += 3;
|
||||
m_SubsoundIndex = a_Stream.ReadInt32();
|
||||
m_PreloadAudioData = a_Stream.ReadBoolean();
|
||||
m_LoadInBackground = a_Stream.ReadBoolean();
|
||||
m_Legacy3D = a_Stream.ReadBoolean();
|
||||
a_Stream.Position += 1;
|
||||
m_LoadType = reader.ReadInt32(); //Decompress on load, Compressed in memory, Streaming
|
||||
m_Channels = reader.ReadInt32();
|
||||
m_Frequency = reader.ReadInt32();
|
||||
m_BitsPerSample = reader.ReadInt32();
|
||||
m_Length = reader.ReadSingle();
|
||||
m_IsTrackerFormat = reader.ReadBoolean();
|
||||
reader.Position += 3;
|
||||
m_SubsoundIndex = reader.ReadInt32();
|
||||
m_PreloadAudioData = reader.ReadBoolean();
|
||||
m_LoadInBackground = reader.ReadBoolean();
|
||||
m_Legacy3D = reader.ReadBoolean();
|
||||
reader.Position += 1;
|
||||
m_3D = m_Legacy3D;
|
||||
|
||||
m_Source = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
if (m_Source != "")
|
||||
m_Source = Path.Combine(Path.GetDirectoryName(sourceFile.filePath), m_Source.Replace("archive:/", ""));
|
||||
m_Offset = a_Stream.ReadInt64();
|
||||
m_Size = a_Stream.ReadInt64();
|
||||
m_CompressionFormat = (AudioCompressionFormat)a_Stream.ReadInt32();
|
||||
m_Source = reader.ReadAlignedString();
|
||||
m_Offset = reader.ReadInt64();
|
||||
m_Size = reader.ReadInt64();
|
||||
m_CompressionFormat = (AudioCompressionFormat)reader.ReadInt32();
|
||||
}
|
||||
|
||||
if (readSwitch)
|
||||
{
|
||||
if (string.IsNullOrEmpty(m_Source))
|
||||
if (!string.IsNullOrEmpty(m_Source))
|
||||
{
|
||||
if (m_Size > 0)
|
||||
m_AudioData = a_Stream.ReadBytes((int)m_Size);
|
||||
}
|
||||
else if (File.Exists(m_Source) ||
|
||||
File.Exists(m_Source = Path.Combine(Path.GetDirectoryName(sourceFile.filePath), Path.GetFileName(m_Source))))
|
||||
{
|
||||
BinaryReader reader = new BinaryReader(File.OpenRead(m_Source));
|
||||
reader.BaseStream.Position = m_Offset;
|
||||
m_AudioData = reader.ReadBytes((int)m_Size);
|
||||
reader.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (UnityStudio.assetsfileandstream.TryGetValue(Path.GetFileName(m_Source), out var estream))
|
||||
var resourceFileName = Path.GetFileName(m_Source);
|
||||
var resourceFilePath = Path.GetDirectoryName(sourceFile.filePath) + "\\" + resourceFileName;
|
||||
if (!File.Exists(resourceFilePath))
|
||||
{
|
||||
estream.Position = m_Offset;
|
||||
m_AudioData = estream.ReadBytes((int)m_Size);
|
||||
var findFiles = Directory.GetFiles(Path.GetDirectoryName(sourceFile.filePath), resourceFileName, SearchOption.AllDirectories);
|
||||
if (findFiles.Length > 0)
|
||||
{
|
||||
resourceFilePath = findFiles[0];
|
||||
}
|
||||
}
|
||||
if (File.Exists(resourceFilePath))
|
||||
{
|
||||
using (var resourceReader = new BinaryReader(File.OpenRead(resourceFilePath)))
|
||||
{
|
||||
resourceReader.BaseStream.Position = m_Offset;
|
||||
m_AudioData = resourceReader.ReadBytes((int)m_Size);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show($"can't find the resource file {Path.GetFileName(m_Source)}");
|
||||
if (Studio.resourceFileReaders.TryGetValue(resourceFileName.ToUpper(), out var resourceReader))
|
||||
{
|
||||
resourceReader.Position = m_Offset;
|
||||
m_AudioData = resourceReader.ReadBytes((int)m_Size);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show($"can't find the resource file {resourceFileName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_Size > 0)
|
||||
m_AudioData = reader.ReadBytes((int)m_Size);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -221,7 +231,7 @@ namespace Unity_Studio
|
||||
break;
|
||||
case AudioCompressionFormat.AAC:
|
||||
preloadData.extension = ".m4a";
|
||||
preloadData.InfoText += "Acc";
|
||||
preloadData.InfoText += "AAC";
|
||||
break;
|
||||
case AudioCompressionFormat.GCADPCM:
|
||||
preloadData.extension = ".fsb";
|
||||
@@ -290,4 +300,35 @@ namespace Unity_Studio
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum AudioType
|
||||
{
|
||||
UNKNOWN,
|
||||
ACC,
|
||||
AIFF,
|
||||
IT = 10,
|
||||
MOD = 12,
|
||||
MPEG,
|
||||
OGGVORBIS,
|
||||
S3M = 17,
|
||||
WAV = 20,
|
||||
XM,
|
||||
XMA,
|
||||
VAG,
|
||||
AUDIOQUEUE
|
||||
}
|
||||
|
||||
public enum AudioCompressionFormat
|
||||
{
|
||||
PCM,
|
||||
Vorbis,
|
||||
ADPCM,
|
||||
MP3,
|
||||
VAG,
|
||||
HEVAG,
|
||||
XMA,
|
||||
AAC,
|
||||
GCADPCM,
|
||||
ATRAC9
|
||||
}
|
||||
}
|
||||
251
AssetStudio/Classes/Avatar.cs
Normal file
251
AssetStudio/Classes/Avatar.cs
Normal file
@@ -0,0 +1,251 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
class Avatar
|
||||
{
|
||||
public string m_Name;
|
||||
private List<KeyValuePair<uint, string>> m_TOS;
|
||||
|
||||
public Avatar(AssetPreloadData preloadData)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var version = sourceFile.version;
|
||||
var reader = preloadData.InitReader();
|
||||
reader.Position = preloadData.Offset;
|
||||
|
||||
m_Name = reader.ReadAlignedString();
|
||||
var m_AvatarSize = reader.ReadUInt32();
|
||||
//AvatarConstant m_Avatar
|
||||
//- OffsetPtr m_AvatarSkeleton
|
||||
//-- Skeleton data
|
||||
//--- vector m_Node
|
||||
var numNodes = reader.ReadInt32();
|
||||
for (int i = 0; i < numNodes; i++)
|
||||
{
|
||||
reader.Position += 8;
|
||||
}
|
||||
//--- vector m_ID
|
||||
int numIDs = reader.ReadInt32();
|
||||
for (int i = 0; i < numIDs; i++)
|
||||
{
|
||||
reader.Position += 4;
|
||||
}
|
||||
//--- vector m_AxesArray
|
||||
int numAxes = reader.ReadInt32();
|
||||
for (int i = 0; i < numAxes; i++)
|
||||
{
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 4))//5.4 and up
|
||||
reader.Position += 76;
|
||||
else
|
||||
reader.Position += 88;
|
||||
}
|
||||
//- OffsetPtr m_AvatarSkeletonPose
|
||||
//-- SkeletonPose data
|
||||
int numXforms = reader.ReadInt32();
|
||||
for (int i = 0; i < numXforms; i++)
|
||||
{
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 4))//5.4 and up
|
||||
reader.Position += 40;
|
||||
else
|
||||
reader.Position += 48;
|
||||
}
|
||||
//- OffsetPtr m_DefaultPose
|
||||
//-- SkeletonPose data
|
||||
numXforms = reader.ReadInt32();
|
||||
for (int i = 0; i < numXforms; i++)
|
||||
{
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 4))//5.4 and up
|
||||
reader.Position += 40;
|
||||
else
|
||||
reader.Position += 48;
|
||||
}
|
||||
//- vector m_SkeletonNameIDArray
|
||||
numIDs = reader.ReadInt32();
|
||||
for (int i = 0; i < numIDs; i++)
|
||||
{
|
||||
reader.Position += 4;
|
||||
}
|
||||
//- OffsetPtr m_Human
|
||||
//-- Human data
|
||||
//--- xform m_RootX
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 4))//5.4 and up
|
||||
reader.Position += 40;
|
||||
else
|
||||
reader.Position += 48;
|
||||
//--- OffsetPtr m_Skeleton
|
||||
//---- Skeleton data
|
||||
numNodes = reader.ReadInt32();
|
||||
for (int i = 0; i < numNodes; i++)
|
||||
{
|
||||
reader.Position += 8;
|
||||
}
|
||||
//--- vector m_ID
|
||||
numIDs = reader.ReadInt32();
|
||||
for (int i = 0; i < numIDs; i++)
|
||||
{
|
||||
reader.Position += 4;
|
||||
}
|
||||
//--- vector m_AxesArray
|
||||
numAxes = reader.ReadInt32();
|
||||
for (int i = 0; i < numAxes; i++)
|
||||
{
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 4))//5.4 and up
|
||||
reader.Position += 76;
|
||||
else
|
||||
reader.Position += 88;
|
||||
}
|
||||
//--- OffsetPtr m_SkeletonPose
|
||||
//---- SkeletonPose data
|
||||
numXforms = reader.ReadInt32();
|
||||
for (int i = 0; i < numXforms; i++)
|
||||
{
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 4))//5.4 and up
|
||||
reader.Position += 40;
|
||||
else
|
||||
reader.Position += 48;
|
||||
}
|
||||
//--- OffsetPtr m_LeftHand
|
||||
//---- Hand data
|
||||
//----- staticvector m_HandBoneIndex
|
||||
int numIndexes = reader.ReadInt32();
|
||||
for (int i = 0; i < numIndexes; i++)
|
||||
{
|
||||
reader.Position += 4;
|
||||
}
|
||||
//--- OffsetPtr m_RightHand
|
||||
numIndexes = reader.ReadInt32();
|
||||
for (int i = 0; i < numIndexes; i++)
|
||||
{
|
||||
reader.Position += 4;
|
||||
}
|
||||
//--- vector m_Handles
|
||||
int numHandles = reader.ReadInt32();
|
||||
for (int i = 0; i < numHandles; i++)
|
||||
{
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 4))//5.4 and up
|
||||
reader.Position += 48;
|
||||
else
|
||||
reader.Position += 56;
|
||||
}
|
||||
//--- vector m_ColliderArray
|
||||
int numColliders = reader.ReadInt32();
|
||||
for (int i = 0; i < numColliders; i++)
|
||||
{
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 4))//5.4 and up
|
||||
reader.Position += 72;
|
||||
else
|
||||
reader.Position += 80;
|
||||
}
|
||||
//--- staticvector m_HumanBoneIndex
|
||||
numIndexes = reader.ReadInt32();
|
||||
for (int i = 0; i < numIndexes; i++)
|
||||
{
|
||||
reader.Position += 4;
|
||||
}
|
||||
//--- staticvector m_HumanBoneMass
|
||||
int numMasses = reader.ReadInt32();
|
||||
for (int i = 0; i < numMasses; i++)
|
||||
{
|
||||
reader.Position += 4;
|
||||
}
|
||||
//--- staticvector m_ColliderIndex
|
||||
int numColliderIndexes = reader.ReadInt32();
|
||||
for (int i = 0; i < numColliderIndexes; i++)
|
||||
{
|
||||
reader.Position += 4;
|
||||
}
|
||||
var m_Scale = reader.ReadSingle();
|
||||
var m_ArmTwist = reader.ReadSingle();
|
||||
var m_ForeArmTwist = reader.ReadSingle();
|
||||
var m_UpperLegTwist = reader.ReadSingle();
|
||||
var m_LegTwist = reader.ReadSingle();
|
||||
var m_ArmStretch = reader.ReadSingle();
|
||||
var m_LegStretch = reader.ReadSingle();
|
||||
var m_FeetSpacing = reader.ReadSingle();
|
||||
var m_HasLeftHand = reader.ReadBoolean();
|
||||
var m_HasRightHand = reader.ReadBoolean();
|
||||
var m_HasTDoF = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
//- vector m_HumanSkeletonIndexArray
|
||||
numIndexes = reader.ReadInt32();
|
||||
for (int i = 0; i < numIndexes; i++)
|
||||
{
|
||||
reader.Position += 4;
|
||||
}
|
||||
//- vector m_HumanSkeletonReverseIndexArray
|
||||
int numReverseIndexes = reader.ReadInt32();
|
||||
for (int i = 0; i < numReverseIndexes; i++)
|
||||
{
|
||||
reader.Position += 4;
|
||||
}
|
||||
var m_RootMotionBoneIndex = reader.ReadInt32();
|
||||
//- xform m_RootMotionBoneX
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 4))//5.4 and up
|
||||
reader.Position += 40;
|
||||
else
|
||||
reader.Position += 48;
|
||||
//- OffsetPtr m_RootMotionSkeleton
|
||||
//-- Skeleton data
|
||||
//--- vector m_Node
|
||||
numNodes = reader.ReadInt32();
|
||||
for (int i = 0; i < numNodes; i++)
|
||||
{
|
||||
reader.Position += 8;
|
||||
}
|
||||
//--- vector m_ID
|
||||
numIDs = reader.ReadInt32();
|
||||
for (int i = 0; i < numIDs; i++)
|
||||
{
|
||||
reader.Position += 4;
|
||||
}
|
||||
//--- vector m_AxesArray
|
||||
numAxes = reader.ReadInt32();
|
||||
for (int i = 0; i < numAxes; i++)
|
||||
{
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 4))//5.4 and up
|
||||
reader.Position += 76;
|
||||
else
|
||||
reader.Position += 88;
|
||||
}
|
||||
//- OffsetPtr m_RootMotionSkeletonPose
|
||||
//-- SkeletonPose data
|
||||
numXforms = reader.ReadInt32();
|
||||
for (int i = 0; i < numXforms; i++)
|
||||
{
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 4))//5.4 and up
|
||||
reader.Position += 40;
|
||||
else
|
||||
reader.Position += 48;
|
||||
}
|
||||
//- vector m_RootMotionSkeletonIndexArray
|
||||
int numMotionIndexes = reader.ReadInt32();
|
||||
for (int i = 0; i < numMotionIndexes; i++)
|
||||
{
|
||||
reader.Position += 4;
|
||||
}
|
||||
//map m_TOS
|
||||
int numTOS = reader.ReadInt32();
|
||||
m_TOS = new List<KeyValuePair<uint, string>>(numTOS);
|
||||
for (int i = 0; i < numTOS; i++)
|
||||
{
|
||||
m_TOS.Add(new KeyValuePair<uint, string>(reader.ReadUInt32(), reader.ReadAlignedString()));
|
||||
}
|
||||
}
|
||||
|
||||
public string FindBoneName(uint hash)
|
||||
{
|
||||
foreach (var pair in m_TOS)
|
||||
{
|
||||
if (pair.Key == hash)
|
||||
{
|
||||
return pair.Value.Substring(pair.Value.LastIndexOf('/') + 1);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
37
AssetStudio/Classes/BuildSettings.cs
Normal file
37
AssetStudio/Classes/BuildSettings.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class BuildSettings
|
||||
{
|
||||
public string m_Version;
|
||||
|
||||
public BuildSettings(AssetPreloadData preloadData)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var reader = preloadData.InitReader();
|
||||
|
||||
int levels = reader.ReadInt32();
|
||||
for (int l = 0; l < levels; l++) { string level = reader.ReadAlignedString(); }
|
||||
|
||||
if (sourceFile.version[0] == 5)
|
||||
{
|
||||
int preloadedPlugins = reader.ReadInt32();
|
||||
for (int l = 0; l < preloadedPlugins; l++) { string preloadedPlugin = reader.ReadAlignedString(); }
|
||||
}
|
||||
|
||||
reader.Position += 4; //bool flags
|
||||
if (sourceFile.fileGen >= 8) { reader.Position += 4; } //bool flags
|
||||
if (sourceFile.fileGen >= 9) { reader.Position += 4; } //bool flags
|
||||
if (sourceFile.version[0] == 5 ||
|
||||
(sourceFile.version[0] == 4 && (sourceFile.version[1] >= 3 ||
|
||||
(sourceFile.version[1] == 2 && sourceFile.buildType[0] != "a"))))
|
||||
{ reader.Position += 4; } //bool flags
|
||||
|
||||
m_Version = reader.ReadAlignedString();
|
||||
}
|
||||
}
|
||||
}
|
||||
190
AssetStudio/Classes/Font.cs
Normal file
190
AssetStudio/Classes/Font.cs
Normal file
@@ -0,0 +1,190 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
class UFont
|
||||
{
|
||||
public string m_Name;
|
||||
public byte[] m_FontData;
|
||||
|
||||
public UFont(AssetPreloadData preloadData, bool readSwitch)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var reader = preloadData.InitReader();
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
{
|
||||
uint m_ObjectHideFlags = reader.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
m_Name = reader.ReadAlignedString();
|
||||
|
||||
if (readSwitch)
|
||||
{
|
||||
if ((sourceFile.version[0] == 5 && sourceFile.version[1] >= 5) || sourceFile.version[0] > 5)
|
||||
{
|
||||
var m_LineSpacing = reader.ReadSingle();
|
||||
var m_DefaultMaterial = sourceFile.ReadPPtr();
|
||||
var m_FontSize = reader.ReadSingle();
|
||||
var m_Texture = sourceFile.ReadPPtr();
|
||||
int m_AsciiStartOffset = reader.ReadInt32();
|
||||
var m_Tracking = reader.ReadSingle();
|
||||
var m_CharacterSpacing = reader.ReadInt32();
|
||||
var m_CharacterPadding = reader.ReadInt32();
|
||||
var m_ConvertCase = reader.ReadInt32();
|
||||
int m_CharacterRects_size = reader.ReadInt32();
|
||||
for (int i = 0; i < m_CharacterRects_size; i++)
|
||||
{
|
||||
int index = reader.ReadInt32();
|
||||
//Rectf uv
|
||||
float uvx = reader.ReadSingle();
|
||||
float uvy = reader.ReadSingle();
|
||||
float uvwidth = reader.ReadSingle();
|
||||
float uvheight = reader.ReadSingle();
|
||||
//Rectf vert
|
||||
float vertx = reader.ReadSingle();
|
||||
float verty = reader.ReadSingle();
|
||||
float vertwidth = reader.ReadSingle();
|
||||
float vertheight = reader.ReadSingle();
|
||||
float width = reader.ReadSingle();
|
||||
|
||||
if (sourceFile.version[0] >= 4)
|
||||
{
|
||||
bool flipped = reader.ReadBoolean();
|
||||
reader.Position += 3;
|
||||
}
|
||||
}
|
||||
int m_KerningValues_size = reader.ReadInt32();
|
||||
for (int i = 0; i < m_KerningValues_size; i++)
|
||||
{
|
||||
int pairfirst = reader.ReadInt16();
|
||||
int pairsecond = reader.ReadInt16();
|
||||
float second = reader.ReadSingle();
|
||||
}
|
||||
var m_PixelScale = reader.ReadSingle();
|
||||
int m_FontData_size = reader.ReadInt32();
|
||||
if (m_FontData_size > 0)
|
||||
{
|
||||
m_FontData = reader.ReadBytes(m_FontData_size);
|
||||
|
||||
if (m_FontData[0] == 79 && m_FontData[1] == 84 && m_FontData[2] == 84 && m_FontData[3] == 79)
|
||||
{ preloadData.extension = ".otf"; }
|
||||
else { preloadData.extension = ".ttf"; }
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int m_AsciiStartOffset = reader.ReadInt32();
|
||||
|
||||
if (sourceFile.version[0] <= 3)
|
||||
{
|
||||
int m_FontCountX = reader.ReadInt32();
|
||||
int m_FontCountY = reader.ReadInt32();
|
||||
}
|
||||
|
||||
float m_Kerning = reader.ReadSingle();
|
||||
float m_LineSpacing = reader.ReadSingle();
|
||||
|
||||
if (sourceFile.version[0] <= 3)
|
||||
{
|
||||
int m_PerCharacterKerning_size = reader.ReadInt32();
|
||||
for (int i = 0; i < m_PerCharacterKerning_size; i++)
|
||||
{
|
||||
int first = reader.ReadInt32();
|
||||
float second = reader.ReadSingle();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int m_CharacterSpacing = reader.ReadInt32();
|
||||
int m_CharacterPadding = reader.ReadInt32();
|
||||
}
|
||||
|
||||
int m_ConvertCase = reader.ReadInt32();
|
||||
PPtr m_DefaultMaterial = sourceFile.ReadPPtr();
|
||||
|
||||
int m_CharacterRects_size = reader.ReadInt32();
|
||||
for (int i = 0; i < m_CharacterRects_size; i++)
|
||||
{
|
||||
int index = reader.ReadInt32();
|
||||
//Rectf uv
|
||||
float uvx = reader.ReadSingle();
|
||||
float uvy = reader.ReadSingle();
|
||||
float uvwidth = reader.ReadSingle();
|
||||
float uvheight = reader.ReadSingle();
|
||||
//Rectf vert
|
||||
float vertx = reader.ReadSingle();
|
||||
float verty = reader.ReadSingle();
|
||||
float vertwidth = reader.ReadSingle();
|
||||
float vertheight = reader.ReadSingle();
|
||||
float width = reader.ReadSingle();
|
||||
|
||||
if (sourceFile.version[0] >= 4)
|
||||
{
|
||||
bool flipped = reader.ReadBoolean();
|
||||
reader.Position += 3;
|
||||
}
|
||||
}
|
||||
|
||||
PPtr m_Texture = sourceFile.ReadPPtr();
|
||||
|
||||
int m_KerningValues_size = reader.ReadInt32();
|
||||
for (int i = 0; i < m_KerningValues_size; i++)
|
||||
{
|
||||
int pairfirst = reader.ReadInt16();
|
||||
int pairsecond = reader.ReadInt16();
|
||||
float second = reader.ReadSingle();
|
||||
}
|
||||
|
||||
if (sourceFile.version[0] <= 3)
|
||||
{
|
||||
bool m_GridFont = reader.ReadBoolean();
|
||||
reader.Position += 3; //4 byte alignment
|
||||
}
|
||||
else { float m_PixelScale = reader.ReadSingle(); }
|
||||
|
||||
int m_FontData_size = reader.ReadInt32();
|
||||
if (m_FontData_size > 0)
|
||||
{
|
||||
m_FontData = reader.ReadBytes(m_FontData_size);
|
||||
|
||||
if (m_FontData[0] == 79 && m_FontData[1] == 84 && m_FontData[2] == 84 && m_FontData[3] == 79)
|
||||
{ preloadData.extension = ".otf"; }
|
||||
else { preloadData.extension = ".ttf"; }
|
||||
|
||||
}
|
||||
|
||||
float m_FontSize = reader.ReadSingle();//problem here in minifootball
|
||||
float m_Ascent = reader.ReadSingle();
|
||||
uint m_DefaultStyle = reader.ReadUInt32();
|
||||
|
||||
int m_FontNames = reader.ReadInt32();
|
||||
for (int i = 0; i < m_FontNames; i++)
|
||||
{
|
||||
string m_FontName = reader.ReadAlignedString();
|
||||
}
|
||||
|
||||
if (sourceFile.version[0] >= 4)
|
||||
{
|
||||
int m_FallbackFonts = reader.ReadInt32();
|
||||
for (int i = 0; i < m_FallbackFonts; i++)
|
||||
{
|
||||
PPtr m_FallbackFont = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
int m_FontRenderingMode = reader.ReadInt32();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
preloadData.Text = m_Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,11 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Unity_Studio
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class GameObject : TreeNode
|
||||
{
|
||||
public AssetPreloadData asset;
|
||||
public List<PPtr> m_Components = new List<PPtr>();
|
||||
public PPtr m_Transform;
|
||||
public PPtr m_MeshRenderer;
|
||||
@@ -24,20 +25,20 @@ namespace Unity_Studio
|
||||
{
|
||||
if (preloadData != null)
|
||||
{
|
||||
asset = preloadData;
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var a_Stream = preloadData.sourceFile.a_Stream;
|
||||
a_Stream.Position = preloadData.Offset;
|
||||
var reader = preloadData.InitReader();
|
||||
|
||||
uniqueID = preloadData.uniqueID;
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
{
|
||||
uint m_ObjectHideFlags = a_Stream.ReadUInt32();
|
||||
uint m_ObjectHideFlags = reader.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
int m_Component_size = a_Stream.ReadInt32();
|
||||
int m_Component_size = reader.ReadInt32();
|
||||
for (int j = 0; j < m_Component_size; j++)
|
||||
{
|
||||
if ((sourceFile.version[0] == 5 && sourceFile.version[1] >= 5) || sourceFile.version[0] > 5)//5.5.0 and up
|
||||
@@ -46,16 +47,16 @@ namespace Unity_Studio
|
||||
}
|
||||
else
|
||||
{
|
||||
int first = a_Stream.ReadInt32();
|
||||
int first = reader.ReadInt32();
|
||||
m_Components.Add(sourceFile.ReadPPtr());
|
||||
}
|
||||
}
|
||||
|
||||
m_Layer = a_Stream.ReadInt32();
|
||||
m_Name = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
m_Layer = reader.ReadInt32();
|
||||
m_Name = reader.ReadAlignedString();
|
||||
if (m_Name == "") { m_Name = "GameObject #" + uniqueID; }
|
||||
m_Tag = a_Stream.ReadUInt16();
|
||||
m_IsActive = a_Stream.ReadBoolean();
|
||||
m_Tag = reader.ReadUInt16();
|
||||
m_IsActive = reader.ReadBoolean();
|
||||
|
||||
Text = m_Name;
|
||||
preloadData.Text = m_Name;
|
||||
@@ -3,11 +3,30 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Unity_Studio
|
||||
namespace AssetStudio
|
||||
{
|
||||
class TexEnv
|
||||
{
|
||||
public string name;
|
||||
public PPtr m_Texture;
|
||||
public float[] m_Scale;
|
||||
public float[] m_Offset;
|
||||
}
|
||||
|
||||
class strFloatPair
|
||||
{
|
||||
public string first;
|
||||
public float second;
|
||||
}
|
||||
|
||||
class strColorPair
|
||||
{
|
||||
public string first;
|
||||
public float[] second;
|
||||
}
|
||||
|
||||
class Material
|
||||
{
|
||||
|
||||
public string m_Name;
|
||||
public PPtr m_Shader;
|
||||
public string[] m_ShaderKeywords;
|
||||
@@ -19,90 +38,89 @@ namespace Unity_Studio
|
||||
public Material(AssetPreloadData preloadData)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var a_Stream = preloadData.sourceFile.a_Stream;
|
||||
a_Stream.Position = preloadData.Offset;
|
||||
var reader = preloadData.InitReader();
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
{
|
||||
uint m_ObjectHideFlags = a_Stream.ReadUInt32();
|
||||
uint m_ObjectHideFlags = reader.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
m_Name = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
m_Name = reader.ReadAlignedString();
|
||||
m_Shader = sourceFile.ReadPPtr();
|
||||
|
||||
if (sourceFile.version[0] == 4 && (sourceFile.version[1] >= 2 || (sourceFile.version[1] == 1 && sourceFile.buildType[0] != "a")))
|
||||
{
|
||||
m_ShaderKeywords = new string[a_Stream.ReadInt32()];
|
||||
m_ShaderKeywords = new string[reader.ReadInt32()];
|
||||
for (int i = 0; i < m_ShaderKeywords.Length; i++)
|
||||
{
|
||||
m_ShaderKeywords[i] = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
m_ShaderKeywords[i] = reader.ReadAlignedString();
|
||||
}
|
||||
}
|
||||
else if (sourceFile.version[0] >= 5)//5.0 and up
|
||||
{
|
||||
m_ShaderKeywords = new[] { a_Stream.ReadAlignedString(a_Stream.ReadInt32()) };
|
||||
uint m_LightmapFlags = a_Stream.ReadUInt32();
|
||||
m_ShaderKeywords = new[] { reader.ReadAlignedString() };
|
||||
uint m_LightmapFlags = reader.ReadUInt32();
|
||||
if (sourceFile.version[0] == 5 && sourceFile.version[1] >= 6 || sourceFile.version[0] > 5)//5.6.0 and up
|
||||
{
|
||||
var m_EnableInstancingVariants = a_Stream.ReadBoolean();
|
||||
var m_EnableInstancingVariants = reader.ReadBoolean();
|
||||
//var m_DoubleSidedGI = a_Stream.ReadBoolean();//2017.x
|
||||
a_Stream.AlignStream(4);
|
||||
reader.AlignStream(4);
|
||||
}
|
||||
}
|
||||
|
||||
if (sourceFile.version[0] > 4 || sourceFile.version[0] == 4 && sourceFile.version[1] >= 3) { m_CustomRenderQueue = a_Stream.ReadInt32(); }
|
||||
if (sourceFile.version[0] > 4 || sourceFile.version[0] == 4 && sourceFile.version[1] >= 3) { m_CustomRenderQueue = reader.ReadInt32(); }
|
||||
|
||||
if (sourceFile.version[0] == 5 && sourceFile.version[1] >= 1 || sourceFile.version[0] > 5)//5.1 and up
|
||||
{
|
||||
string[][] stringTagMap = new string[a_Stream.ReadInt32()][];
|
||||
string[][] stringTagMap = new string[reader.ReadInt32()][];
|
||||
for (int i = 0; i < stringTagMap.Length; i++)
|
||||
{
|
||||
stringTagMap[i] = new[] { a_Stream.ReadAlignedString(a_Stream.ReadInt32()), a_Stream.ReadAlignedString(a_Stream.ReadInt32()) };
|
||||
stringTagMap[i] = new[] { reader.ReadAlignedString(), reader.ReadAlignedString() };
|
||||
}
|
||||
}
|
||||
//disabledShaderPasses
|
||||
if ((sourceFile.version[0] == 5 && sourceFile.version[1] >= 6) || sourceFile.version[0] > 5)//5.6.0 and up
|
||||
{
|
||||
var size = a_Stream.ReadInt32();
|
||||
var size = reader.ReadInt32();
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
reader.ReadAlignedString();
|
||||
}
|
||||
}
|
||||
//m_SavedProperties
|
||||
m_TexEnvs = new TexEnv[a_Stream.ReadInt32()];
|
||||
m_TexEnvs = new TexEnv[reader.ReadInt32()];
|
||||
for (int i = 0; i < m_TexEnvs.Length; i++)
|
||||
{
|
||||
TexEnv m_TexEnv = new TexEnv()
|
||||
{
|
||||
name = a_Stream.ReadAlignedString(a_Stream.ReadInt32()),
|
||||
name = reader.ReadAlignedString(),
|
||||
m_Texture = sourceFile.ReadPPtr(),
|
||||
m_Scale = new[] { a_Stream.ReadSingle(), a_Stream.ReadSingle() },
|
||||
m_Offset = new[] { a_Stream.ReadSingle(), a_Stream.ReadSingle() }
|
||||
m_Scale = new[] { reader.ReadSingle(), reader.ReadSingle() },
|
||||
m_Offset = new[] { reader.ReadSingle(), reader.ReadSingle() }
|
||||
};
|
||||
m_TexEnvs[i] = m_TexEnv;
|
||||
}
|
||||
|
||||
m_Floats = new strFloatPair[a_Stream.ReadInt32()];
|
||||
m_Floats = new strFloatPair[reader.ReadInt32()];
|
||||
for (int i = 0; i < m_Floats.Length; i++)
|
||||
{
|
||||
strFloatPair m_Float = new strFloatPair()
|
||||
{
|
||||
first = a_Stream.ReadAlignedString(a_Stream.ReadInt32()),
|
||||
second = a_Stream.ReadSingle()
|
||||
first = reader.ReadAlignedString(),
|
||||
second = reader.ReadSingle()
|
||||
};
|
||||
m_Floats[i] = m_Float;
|
||||
}
|
||||
|
||||
m_Colors = new strColorPair[a_Stream.ReadInt32()];
|
||||
m_Colors = new strColorPair[reader.ReadInt32()];
|
||||
for (int i = 0; i < m_Colors.Length; i++)
|
||||
{
|
||||
strColorPair m_Color = new strColorPair()
|
||||
{
|
||||
first = a_Stream.ReadAlignedString(a_Stream.ReadInt32()),
|
||||
second = new[] { a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() }
|
||||
first = reader.ReadAlignedString(),
|
||||
second = new[] { reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() }
|
||||
};
|
||||
m_Colors[i] = m_Color;
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using SharpDX;
|
||||
|
||||
/*Notes about handedness
|
||||
Converting from left-handed to right-handed and vice versa requires either:
|
||||
@@ -16,7 +17,7 @@ Also, rotating the axes is just that, the same handedness in a different system.
|
||||
|
||||
Y-up or Z-up are not requirements OR defining characteristics of a handedness, they are just common that way.
|
||||
|
||||
Unity is left-handed with Y-up
|
||||
unt is left-handed with Y-up
|
||||
Aircraft View
|
||||
Y Top Y Up
|
||||
| |
|
||||
@@ -24,9 +25,9 @@ Y Top Y Up
|
||||
| / |
|
||||
| / |
|
||||
+--------X X--------+
|
||||
Right to the \
|
||||
left \
|
||||
Z towards viewer
|
||||
Right to the \
|
||||
left \
|
||||
Z towards viewer
|
||||
|
||||
3ds Max is right-handed with Z up
|
||||
Aircraft View
|
||||
@@ -36,7 +37,7 @@ Z Top Z Up (Viewcube Top)
|
||||
| / from \ |
|
||||
| / viewer \ |
|
||||
+--------(-X) (VC Back) +--------X to the right
|
||||
Right (Viewcube Right)
|
||||
Right (Viewcube Right)
|
||||
|
||||
|
||||
|
||||
@@ -48,10 +49,10 @@ Y Top Y Up (Viewcube Top)
|
||||
| / |
|
||||
| / |
|
||||
+--------(-X) +--------X to the right
|
||||
Right \ (Viewcube Right)
|
||||
\
|
||||
Z towards viewer
|
||||
(Viewcube Front)
|
||||
Right \ (Viewcube Right)
|
||||
\
|
||||
Z towards viewer
|
||||
(Viewcube Front)
|
||||
|
||||
Exporting FBX from Max, vertex components are ALWAYS written as they are in max: X Y Z.
|
||||
The Axis option only affects GlobalSettings and PreRotation in the FBX file.
|
||||
@@ -69,40 +70,40 @@ PreRotation -90,0,0 to bring Original Up (FBX Z) to ViewCube Up when importing
|
||||
PreRotation means only the geometry is rotated locally around pivot before applying other modifiers. It is "invisible" to the user.
|
||||
|
||||
|
||||
Importing FBX in Unity, Axis settings and PreRotations are ignored.
|
||||
They probably ignore them because the order of vertex components is always the same in FBX, and Unity axes never change orientation (as opposed to Max-Maya).
|
||||
Importing FBX in Unt, Axis settings and PreRotations are ignored.
|
||||
They probably ignore them because the order of vertex components is always the same in FBX, and Unt axes never change orientation (as opposed to Max-Maya).
|
||||
Vertex components are loaded as follows:
|
||||
Unity Up(Y) = FBX Y
|
||||
Unity Front(Z) = FBX Z
|
||||
Unity Left(X) = FBX -X
|
||||
Unt Up(Y) = FBX Y
|
||||
Unt Front(Z) = FBX Z
|
||||
Unt Left(X) = FBX -X
|
||||
|
||||
Technically, this is a correct handedness conversion, but to a different system, because the model is not properly oriented (plane nose is down).
|
||||
So Unity adds a -90 degree rotation, similar to the FBX PreRotation, to bring the nose to Front(Z).
|
||||
So Unt adds a -90 degree rotation, similar to the FBX PreRotation, to bring the nose to Front(Z).
|
||||
Except it does it as a regular rotation, and combines it with any other rotations in the Transform asset.
|
||||
|
||||
Converting from Unity back to FBX, the same vertex conversion cannot be applied because we have to take into account the rotation.
|
||||
Converting from Unt back to FBX, the same vertex conversion cannot be applied because we have to take into account the rotation.
|
||||
Option 0: export vertices and transformations as -X,Y,Z and set FBX option to Y-up without PreRotation!
|
||||
the result will be Max Z = FBX Y, Max -Y = FBX Z, Max X = FBX X => final order -X -Z Y
|
||||
Option 1: export vertices and transformations as -X,-Z,Y and set FBX options as "Z-up".
|
||||
The -90 rotation exported from Unity will bring the model in correct orientation.
|
||||
The -90 rotation exported from Unt will bring the model in correct orientation.
|
||||
Option 2: export vertices and transformations as -X,-Y,-Z, add -90 PreRotation to every Mesh Node and set FBX options as "Y-up".
|
||||
The -90 rotation from Unity plus the -90 PreRotation will bring the model in correct orientation.
|
||||
The -90 rotation from Unt plus the -90 PreRotation will bring the model in correct orientation.
|
||||
Remember though that the PreRotation is baked into the Geometry.
|
||||
|
||||
But since the -90 rotation from Unity is a regular type, it will show up in the modifier in both cases.
|
||||
Also, re-importing this FBX in Unity will now produce a (-90)+(-90)=-180 rotation.
|
||||
But since the -90 rotation from Unt is a regular type, it will show up in the modifier in both cases.
|
||||
Also, re-importing this FBX in Unt will now produce a (-90)+(-90)=-180 rotation.
|
||||
This is an unfortunate eyesore, but nothing more, the orientation will be fine.
|
||||
|
||||
In theory, one could add +90 degrees rotation to GameObjects that link to Mesh assets (but not other types) to cancel out the Unity rotation.
|
||||
The problem is you can never know where the Unity mesh originated from. If it came from a left-handed format such as OBJ, there wouldn't have been any conversion and it wouldn't have that -90 degree adjustment.
|
||||
In theory, one could add +90 degrees rotation to GameObjects that link to Mesh assets (but not other types) to cancel out the Unt rotation.
|
||||
The problem is you can never know where the Unt mesh originated from. If it came from a left-handed format such as OBJ, there wouldn't have been any conversion and it wouldn't have that -90 degree adjustment.
|
||||
So it would "fix" meshes that were originally sourced form FBX, but would still have the "extra" rotation in mehses sourced from left-handed formats.
|
||||
*/
|
||||
|
||||
namespace Unity_Studio
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class Mesh
|
||||
{
|
||||
private EndianBinaryReader a_Stream;
|
||||
private EndianBinaryReader reader;
|
||||
public string m_Name;
|
||||
public List<SubMesh> m_SubMeshes = new List<SubMesh>();
|
||||
public List<uint> m_Indices = new List<uint>(); //use a list because I don't always know the facecount for triangle strips
|
||||
@@ -122,6 +123,8 @@ namespace Unity_Studio
|
||||
public float[] m_UV3;
|
||||
public float[] m_UV4;
|
||||
public float[] m_Tangents;
|
||||
public uint[] m_BoneNameHashes;
|
||||
public BlendShapeData m_Shapes;
|
||||
|
||||
public class SubMesh
|
||||
{
|
||||
@@ -166,10 +169,104 @@ namespace Unity_Studio
|
||||
public byte m_BitSize;
|
||||
}
|
||||
|
||||
public class BlendShapeData
|
||||
{
|
||||
public class BlendShapeVertex
|
||||
{
|
||||
public Vector3 vertex { get; set; }
|
||||
public Vector3 normal { get; set; }
|
||||
public Vector3 tangent { get; set; }
|
||||
public uint index { get; set; }
|
||||
|
||||
public BlendShapeVertex() { }
|
||||
|
||||
public BlendShapeVertex(EndianBinaryReader reader)
|
||||
{
|
||||
vertex = reader.ReadVector3();
|
||||
normal = reader.ReadVector3();
|
||||
tangent = reader.ReadVector3();
|
||||
index = reader.ReadUInt32();
|
||||
}
|
||||
}
|
||||
|
||||
public class MeshBlendShape
|
||||
{
|
||||
public uint firstVertex { get; set; }
|
||||
public uint vertexCount { get; set; }
|
||||
public bool hasNormals { get; set; }
|
||||
public bool hasTangents { get; set; }
|
||||
|
||||
public MeshBlendShape() { }
|
||||
|
||||
public MeshBlendShape(EndianBinaryReader reader)
|
||||
{
|
||||
firstVertex = reader.ReadUInt32();
|
||||
vertexCount = reader.ReadUInt32();
|
||||
hasNormals = reader.ReadBoolean();
|
||||
hasTangents = reader.ReadBoolean();
|
||||
reader.ReadBytes(2);
|
||||
}
|
||||
}
|
||||
|
||||
public class MeshBlendShapeChannel
|
||||
{
|
||||
public string name { get; set; }
|
||||
public uint nameHash { get; set; }
|
||||
public int frameIndex { get; set; }
|
||||
public int frameCount { get; set; }
|
||||
|
||||
public MeshBlendShapeChannel() { }
|
||||
|
||||
public MeshBlendShapeChannel(EndianBinaryReader reader)
|
||||
{
|
||||
name = reader.ReadStringToNull();
|
||||
nameHash = reader.ReadUInt32();
|
||||
frameIndex = reader.ReadInt32();
|
||||
frameCount = reader.ReadInt32();
|
||||
}
|
||||
}
|
||||
|
||||
public List<BlendShapeVertex> vertices { get; set; }
|
||||
public List<MeshBlendShape> shapes { get; set; }
|
||||
public List<MeshBlendShapeChannel> channels { get; set; }
|
||||
public List<float> fullWeights { get; set; }
|
||||
|
||||
public BlendShapeData(EndianBinaryReader reader)
|
||||
{
|
||||
int numVerts = reader.ReadInt32();
|
||||
vertices = new List<BlendShapeVertex>(numVerts);
|
||||
for (int i = 0; i < numVerts; i++)
|
||||
{
|
||||
vertices.Add(new BlendShapeVertex(reader));
|
||||
}
|
||||
|
||||
int numShapes = reader.ReadInt32();
|
||||
shapes = new List<MeshBlendShape>(numShapes);
|
||||
for (int i = 0; i < numShapes; i++)
|
||||
{
|
||||
shapes.Add(new MeshBlendShape(reader));
|
||||
}
|
||||
|
||||
int numChannels = reader.ReadInt32();
|
||||
channels = new List<MeshBlendShapeChannel>(numChannels);
|
||||
for (int i = 0; i < numChannels; i++)
|
||||
{
|
||||
channels.Add(new MeshBlendShapeChannel(reader));
|
||||
}
|
||||
|
||||
int numWeights = reader.ReadInt32();
|
||||
fullWeights = new List<float>(numWeights);
|
||||
for (int i = 0; i < numWeights; i++)
|
||||
{
|
||||
fullWeights.Add(reader.ReadSingle());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float bytesToFloat(byte[] inputBytes)
|
||||
{
|
||||
float result = 0;
|
||||
if (a_Stream.endian == EndianType.BigEndian) { Array.Reverse(inputBytes); }
|
||||
if (reader.endian == EndianType.BigEndian) { Array.Reverse(inputBytes); }
|
||||
|
||||
switch (inputBytes.Length)
|
||||
{
|
||||
@@ -177,7 +274,7 @@ namespace Unity_Studio
|
||||
result = inputBytes[0] / 255.0f;
|
||||
break;
|
||||
case 2:
|
||||
result = Half.ToHalf(inputBytes, 0);
|
||||
result = System.Half.ToHalf(inputBytes, 0);
|
||||
break;
|
||||
case 4:
|
||||
result = BitConverter.ToSingle(inputBytes, 0);
|
||||
@@ -331,69 +428,69 @@ namespace Unity_Studio
|
||||
//Stream = new EndianStream(File.OpenRead(sourceFile.filePath), sourceFile.endianType);
|
||||
//Stream.endian = sourceFile.endianType;
|
||||
var version = MeshPD.sourceFile.version;
|
||||
a_Stream = MeshPD.sourceFile.a_Stream;
|
||||
a_Stream.Position = MeshPD.Offset;
|
||||
reader = MeshPD.InitReader();
|
||||
|
||||
bool m_Use16BitIndices = true; //3.5.0 and newer always uses 16bit indices
|
||||
uint m_MeshCompression = 0;
|
||||
|
||||
if (MeshPD.sourceFile.platform == -2)
|
||||
{
|
||||
uint m_ObjectHideFlags = a_Stream.ReadUInt32();
|
||||
uint m_ObjectHideFlags = reader.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = MeshPD.sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = MeshPD.sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
m_Name = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
m_Name = reader.ReadAlignedString();
|
||||
|
||||
if (readSwitch)
|
||||
{
|
||||
|
||||
if (version[0] < 3 || (version[0] == 3 && version[1] < 5))
|
||||
{
|
||||
m_Use16BitIndices = a_Stream.ReadBoolean();
|
||||
a_Stream.Position += 3;
|
||||
m_Use16BitIndices = reader.ReadBoolean();
|
||||
reader.Position += 3;
|
||||
}
|
||||
|
||||
#region Index Buffer for 2.5.1 and earlier
|
||||
if (version[0] == 2 && version[1] <= 5)
|
||||
{
|
||||
int m_IndexBuffer_size = a_Stream.ReadInt32();
|
||||
int m_IndexBuffer_size = reader.ReadInt32();
|
||||
|
||||
if (m_Use16BitIndices)
|
||||
{
|
||||
m_IndexBuffer = new uint[m_IndexBuffer_size / 2];
|
||||
for (int i = 0; i < m_IndexBuffer_size / 2; i++) { m_IndexBuffer[i] = a_Stream.ReadUInt16(); }
|
||||
a_Stream.AlignStream(4);
|
||||
for (int i = 0; i < m_IndexBuffer_size / 2; i++) { m_IndexBuffer[i] = reader.ReadUInt16(); }
|
||||
reader.AlignStream(4);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_IndexBuffer = new uint[m_IndexBuffer_size / 4];
|
||||
for (int i = 0; i < m_IndexBuffer_size / 4; i++) { m_IndexBuffer[i] = a_Stream.ReadUInt32(); }
|
||||
for (int i = 0; i < m_IndexBuffer_size / 4; i++) { m_IndexBuffer[i] = reader.ReadUInt32(); }
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region subMeshes
|
||||
int m_SubMeshes_size = a_Stream.ReadInt32();
|
||||
int m_SubMeshes_size = reader.ReadInt32();
|
||||
for (int s = 0; s < m_SubMeshes_size; s++)
|
||||
{
|
||||
m_SubMeshes.Add(new SubMesh());
|
||||
m_SubMeshes[s].firstByte = a_Stream.ReadUInt32();
|
||||
m_SubMeshes[s].indexCount = a_Stream.ReadUInt32(); //what is this in case of triangle strips?
|
||||
m_SubMeshes[s].topology = a_Stream.ReadInt32(); //isTriStrip
|
||||
m_SubMeshes[s].firstByte = reader.ReadUInt32();
|
||||
m_SubMeshes[s].indexCount = reader.ReadUInt32(); //what is this in case of triangle strips?
|
||||
m_SubMeshes[s].topology = reader.ReadInt32(); //isTriStrip
|
||||
if (version[0] < 4)
|
||||
{
|
||||
m_SubMeshes[s].triangleCount = a_Stream.ReadUInt32();
|
||||
m_SubMeshes[s].triangleCount = reader.ReadUInt32();
|
||||
}
|
||||
if (version[0] >= 3)
|
||||
{
|
||||
if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 3))//2017.3 and up
|
||||
{
|
||||
var baseVertex = a_Stream.ReadUInt32();
|
||||
var baseVertex = reader.ReadUInt32();
|
||||
}
|
||||
m_SubMeshes[s].firstVertex = a_Stream.ReadUInt32();
|
||||
m_SubMeshes[s].vertexCount = a_Stream.ReadUInt32();
|
||||
a_Stream.Position += 24; //Axis-Aligned Bounding Box
|
||||
m_SubMeshes[s].firstVertex = reader.ReadUInt32();
|
||||
m_SubMeshes[s].vertexCount = reader.ReadUInt32();
|
||||
reader.Position += 24; //Axis-Aligned Bounding Box
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
@@ -402,90 +499,79 @@ namespace Unity_Studio
|
||||
if (version[0] == 4 && ((version[1] == 1 && MeshPD.sourceFile.buildType[0] != "a") ||
|
||||
(version[1] > 1 && version[1] <= 2)))
|
||||
{
|
||||
int m_Shapes_size = a_Stream.ReadInt32();
|
||||
int m_Shapes_size = reader.ReadInt32();
|
||||
if (m_Shapes_size > 0)
|
||||
{
|
||||
//bool stop = true;
|
||||
}
|
||||
for (int s = 0; s < m_Shapes_size; s++) //untested
|
||||
{
|
||||
string shape_name = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
a_Stream.Position += 36; //uint firstVertex, vertexCount; Vector3f aabbMinDelta, aabbMaxDelta; bool hasNormals, hasTangents
|
||||
string shape_name = reader.ReadAlignedString();
|
||||
reader.Position += 36; //uint firstVertex, vertexCount; Vector3f aabbMinDelta, aabbMaxDelta; bool hasNormals, hasTangents
|
||||
}
|
||||
|
||||
int m_ShapeVertices_size = a_Stream.ReadInt32();
|
||||
a_Stream.Position += m_ShapeVertices_size * 40; //vertex positions, normals, tangents & uint index
|
||||
int m_ShapeVertices_size = reader.ReadInt32();
|
||||
reader.Position += m_ShapeVertices_size * 40; //vertex positions, normals, tangents & uint index
|
||||
}
|
||||
#endregion
|
||||
#region BlendShapeData and BindPose for 4.3.0 and later
|
||||
else if (version[0] >= 5 || (version[0] == 4 && version[1] >= 3))
|
||||
{
|
||||
int m_ShapeVertices_size = a_Stream.ReadInt32();
|
||||
if (m_ShapeVertices_size > 0)
|
||||
{
|
||||
//bool stop = true;
|
||||
}
|
||||
a_Stream.Position += m_ShapeVertices_size * 40; //vertex positions, normals, tangents & uint index
|
||||
m_Shapes = new BlendShapeData(reader);//TODO 4.3 down
|
||||
|
||||
int shapes_size = a_Stream.ReadInt32();
|
||||
a_Stream.Position += shapes_size * 12; //uint firstVertex, vertexCount; bool hasNormals, hasTangents
|
||||
|
||||
int channels_size = a_Stream.ReadInt32();
|
||||
for (int c = 0; c < channels_size; c++)
|
||||
{
|
||||
string channel_name = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
a_Stream.Position += 12; //uint nameHash; int frameIndex, frameCount
|
||||
}
|
||||
|
||||
int fullWeights_size = a_Stream.ReadInt32();
|
||||
a_Stream.Position += fullWeights_size * 4; //floats
|
||||
|
||||
m_BindPose = new float[a_Stream.ReadInt32()][,];
|
||||
m_BindPose = new float[reader.ReadInt32()][,];
|
||||
for (int i = 0; i < m_BindPose.Length; i++)
|
||||
{
|
||||
m_BindPose[i] = new[,] {
|
||||
{ a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() },
|
||||
{ a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() },
|
||||
{ a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() },
|
||||
{ a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() } };
|
||||
{ reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() },
|
||||
{ reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() },
|
||||
{ reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() },
|
||||
{ reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() } };
|
||||
}
|
||||
|
||||
int m_BoneNameHashes_size = a_Stream.ReadInt32();
|
||||
a_Stream.Position += m_BoneNameHashes_size * 4; //uints
|
||||
int m_BoneNameHashes_size = reader.ReadInt32();
|
||||
m_BoneNameHashes = new uint[m_BoneNameHashes_size];
|
||||
for (int i = 0; i < m_BoneNameHashes_size; i++)
|
||||
{
|
||||
m_BoneNameHashes[i] = reader.ReadUInt32();
|
||||
}
|
||||
|
||||
uint m_RootBoneNameHash = a_Stream.ReadUInt32();
|
||||
uint m_RootBoneNameHash = reader.ReadUInt32();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Index Buffer for 2.6.0 and later
|
||||
if (version[0] >= 3 || (version[0] == 2 && version[1] >= 6))
|
||||
{
|
||||
m_MeshCompression = a_Stream.ReadByte();
|
||||
m_MeshCompression = reader.ReadByte();
|
||||
if (version[0] >= 4)
|
||||
{
|
||||
if (version[0] < 5) { uint m_StreamCompression = a_Stream.ReadByte(); }
|
||||
bool m_IsReadable = a_Stream.ReadBoolean();
|
||||
bool m_KeepVertices = a_Stream.ReadBoolean();
|
||||
bool m_KeepIndices = a_Stream.ReadBoolean();
|
||||
if (version[0] < 5) { uint m_StreamCompression = reader.ReadByte(); }
|
||||
bool m_IsReadable = reader.ReadBoolean();
|
||||
bool m_KeepVertices = reader.ReadBoolean();
|
||||
bool m_KeepIndices = reader.ReadBoolean();
|
||||
}
|
||||
a_Stream.AlignStream(4);
|
||||
if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 3))//2017.3 and up
|
||||
reader.AlignStream(4);
|
||||
//This is a bug fixed in 2017.3.1p1 and later versions
|
||||
if ((version[0] > 2017 || (version[0] == 2017 && version[1] >= 4)) || //2017.4
|
||||
((version[0] == 2017 && version[1] == 3 && version[2] == 1) && MeshPD.sourceFile.buildType[0] == "p") || //fixed after 2017.3.1px
|
||||
((version[0] == 2017 && version[1] == 3) && m_MeshCompression == 0))//2017.3.xfx with no compression
|
||||
{
|
||||
var m_IndexFormat = a_Stream.ReadInt32();
|
||||
var m_IndexFormat = reader.ReadInt32();
|
||||
}
|
||||
int m_IndexBuffer_size = a_Stream.ReadInt32();
|
||||
int m_IndexBuffer_size = reader.ReadInt32();
|
||||
|
||||
if (m_Use16BitIndices)
|
||||
{
|
||||
m_IndexBuffer = new uint[m_IndexBuffer_size / 2];
|
||||
for (int i = 0; i < m_IndexBuffer_size / 2; i++) { m_IndexBuffer[i] = a_Stream.ReadUInt16(); }
|
||||
a_Stream.AlignStream(4);
|
||||
for (int i = 0; i < m_IndexBuffer_size / 2; i++) { m_IndexBuffer[i] = reader.ReadUInt16(); }
|
||||
reader.AlignStream(4);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_IndexBuffer = new uint[m_IndexBuffer_size / 4];
|
||||
for (int i = 0; i < m_IndexBuffer_size / 4; i++) { m_IndexBuffer[i] = a_Stream.ReadUInt32(); }
|
||||
a_Stream.AlignStream(4);//untested
|
||||
for (int i = 0; i < m_IndexBuffer_size / 4; i++) { m_IndexBuffer[i] = reader.ReadUInt32(); }
|
||||
reader.AlignStream(4);//untested
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
@@ -493,17 +579,17 @@ namespace Unity_Studio
|
||||
#region Vertex Buffer for 3.4.2 and earlier
|
||||
if (version[0] < 3 || (version[0] == 3 && version[1] < 5))
|
||||
{
|
||||
m_VertexCount = a_Stream.ReadInt32();
|
||||
m_VertexCount = reader.ReadInt32();
|
||||
m_Vertices = new float[m_VertexCount * 3];
|
||||
for (int v = 0; v < m_VertexCount * 3; v++) { m_Vertices[v] = a_Stream.ReadSingle(); }
|
||||
for (int v = 0; v < m_VertexCount * 3; v++) { m_Vertices[v] = reader.ReadSingle(); }
|
||||
|
||||
m_Skin = new List<BoneInfluence>[a_Stream.ReadInt32()];
|
||||
m_Skin = new List<BoneInfluence>[reader.ReadInt32()];
|
||||
//m_Skin = new Dictionary<int, float>[a_Stream.ReadInt32()];
|
||||
for (int s = 0; s < m_Skin.Length; s++)
|
||||
{
|
||||
m_Skin[s] = new List<BoneInfluence>();
|
||||
for (int i = 0; i < 4; i++) { m_Skin[s].Add(new BoneInfluence() { weight = a_Stream.ReadSingle() }); }
|
||||
for (int i = 0; i < 4; i++) { m_Skin[s][i].boneIndex = a_Stream.ReadInt32(); }
|
||||
for (int i = 0; i < 4; i++) { m_Skin[s].Add(new BoneInfluence() { weight = reader.ReadSingle() }); }
|
||||
for (int i = 0; i < 4; i++) { m_Skin[s][i].boneIndex = reader.ReadInt32(); }
|
||||
|
||||
/*m_Skin[s] = new Dictionary<int, float>();
|
||||
float[] weights = new float[4] { a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() };
|
||||
@@ -514,44 +600,44 @@ namespace Unity_Studio
|
||||
}*/
|
||||
}
|
||||
|
||||
m_BindPose = new float[a_Stream.ReadInt32()][,];
|
||||
m_BindPose = new float[reader.ReadInt32()][,];
|
||||
for (int i = 0; i < m_BindPose.Length; i++)
|
||||
{
|
||||
m_BindPose[i] = new[,] {
|
||||
{ a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() },
|
||||
{ a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() },
|
||||
{ a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() },
|
||||
{ a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() } };
|
||||
{ reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() },
|
||||
{ reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() },
|
||||
{ reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() },
|
||||
{ reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() } };
|
||||
}
|
||||
|
||||
int m_UV1_size = a_Stream.ReadInt32();
|
||||
int m_UV1_size = reader.ReadInt32();
|
||||
m_UV1 = new float[m_UV1_size * 2];
|
||||
for (int v = 0; v < m_UV1_size * 2; v++) { m_UV1[v] = a_Stream.ReadSingle(); }
|
||||
for (int v = 0; v < m_UV1_size * 2; v++) { m_UV1[v] = reader.ReadSingle(); }
|
||||
|
||||
int m_UV2_size = a_Stream.ReadInt32();
|
||||
int m_UV2_size = reader.ReadInt32();
|
||||
m_UV2 = new float[m_UV2_size * 2];
|
||||
for (int v = 0; v < m_UV2_size * 2; v++) { m_UV2[v] = a_Stream.ReadSingle(); }
|
||||
for (int v = 0; v < m_UV2_size * 2; v++) { m_UV2[v] = reader.ReadSingle(); }
|
||||
|
||||
if (version[0] == 2 && version[1] <= 5)
|
||||
{
|
||||
int m_TangentSpace_size = a_Stream.ReadInt32();
|
||||
int m_TangentSpace_size = reader.ReadInt32();
|
||||
m_Normals = new float[m_TangentSpace_size * 3];
|
||||
for (int v = 0; v < m_TangentSpace_size; v++)
|
||||
{
|
||||
m_Normals[v * 3] = a_Stream.ReadSingle();
|
||||
m_Normals[v * 3 + 1] = a_Stream.ReadSingle();
|
||||
m_Normals[v * 3 + 2] = a_Stream.ReadSingle();
|
||||
a_Stream.Position += 16; //Vector3f tangent & float handedness
|
||||
m_Normals[v * 3] = reader.ReadSingle();
|
||||
m_Normals[v * 3 + 1] = reader.ReadSingle();
|
||||
m_Normals[v * 3 + 2] = reader.ReadSingle();
|
||||
reader.Position += 16; //Vector3f tangent & float handedness
|
||||
}
|
||||
}
|
||||
else //2.6.0 and later
|
||||
{
|
||||
int m_Tangents_size = a_Stream.ReadInt32();
|
||||
a_Stream.Position += m_Tangents_size * 16; //Vector4f
|
||||
int m_Tangents_size = reader.ReadInt32();
|
||||
reader.Position += m_Tangents_size * 16; //Vector4f
|
||||
|
||||
int m_Normals_size = a_Stream.ReadInt32();
|
||||
int m_Normals_size = reader.ReadInt32();
|
||||
m_Normals = new float[m_Normals_size * 3];
|
||||
for (int v = 0; v < m_Normals_size * 3; v++) { m_Normals[v] = a_Stream.ReadSingle(); }
|
||||
for (int v = 0; v < m_Normals_size * 3; v++) { m_Normals[v] = reader.ReadSingle(); }
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
@@ -559,13 +645,13 @@ namespace Unity_Studio
|
||||
else
|
||||
{
|
||||
#region read vertex stream
|
||||
m_Skin = new List<BoneInfluence>[a_Stream.ReadInt32()];
|
||||
m_Skin = new List<BoneInfluence>[reader.ReadInt32()];
|
||||
//m_Skin = new Dictionary<int, float>[a_Stream.ReadInt32()];
|
||||
for (int s = 0; s < m_Skin.Length; s++)
|
||||
{
|
||||
m_Skin[s] = new List<BoneInfluence>();
|
||||
for (int i = 0; i < 4; i++) { m_Skin[s].Add(new BoneInfluence() { weight = a_Stream.ReadSingle() }); }
|
||||
for (int i = 0; i < 4; i++) { m_Skin[s][i].boneIndex = a_Stream.ReadInt32(); }
|
||||
for (int i = 0; i < 4; i++) { m_Skin[s].Add(new BoneInfluence() { weight = reader.ReadSingle() }); }
|
||||
for (int i = 0; i < 4; i++) { m_Skin[s][i].boneIndex = reader.ReadInt32(); }
|
||||
|
||||
/*m_Skin[s] = new Dictionary<int, float>();
|
||||
float[] weights = new float[4] { a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() };
|
||||
@@ -579,20 +665,20 @@ namespace Unity_Studio
|
||||
|
||||
if (version[0] == 3 || (version[0] == 4 && version[1] <= 2))
|
||||
{
|
||||
m_BindPose = new float[a_Stream.ReadInt32()][,];
|
||||
m_BindPose = new float[reader.ReadInt32()][,];
|
||||
for (int i = 0; i < m_BindPose.Length; i++)
|
||||
{
|
||||
m_BindPose[i] = new[,] {
|
||||
{ a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() },
|
||||
{ a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() },
|
||||
{ a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() },
|
||||
{ a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() } };
|
||||
{ reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() },
|
||||
{ reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() },
|
||||
{ reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() },
|
||||
{ reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() } };
|
||||
}
|
||||
}
|
||||
|
||||
BitArray m_CurrentChannels = new BitArray(new int[1] { a_Stream.ReadInt32() });
|
||||
m_VertexCount = a_Stream.ReadInt32();
|
||||
//int singleStreamStride = 0;//used tor unity 5
|
||||
BitArray m_CurrentChannels = new BitArray(new int[1] { reader.ReadInt32() });
|
||||
m_VertexCount = reader.ReadInt32();
|
||||
//int singleStreamStride = 0;//used tor version 5
|
||||
int streamCount = 0;
|
||||
|
||||
#region streams for 3.5.0 - 3.5.7
|
||||
@@ -600,7 +686,7 @@ namespace Unity_Studio
|
||||
{
|
||||
if (m_MeshCompression != 0 && version[2] == 0) //special case not just on platform 9
|
||||
{
|
||||
a_Stream.Position += 12;
|
||||
reader.Position += 12;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -608,10 +694,10 @@ namespace Unity_Studio
|
||||
for (int s = 0; s < 4; s++)
|
||||
{
|
||||
m_Streams[s] = new StreamInfo();
|
||||
m_Streams[s].channelMask = new BitArray(new int[1] { a_Stream.ReadInt32() });
|
||||
m_Streams[s].offset = a_Stream.ReadInt32();
|
||||
m_Streams[s].stride = a_Stream.ReadInt32();
|
||||
m_Streams[s].align = a_Stream.ReadUInt32();
|
||||
m_Streams[s].channelMask = new BitArray(new int[1] { reader.ReadInt32() });
|
||||
m_Streams[s].offset = reader.ReadInt32();
|
||||
m_Streams[s].stride = reader.ReadInt32();
|
||||
m_Streams[s].align = reader.ReadUInt32();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -619,16 +705,16 @@ namespace Unity_Studio
|
||||
#region channels and streams for 4.0.0 and later
|
||||
else
|
||||
{
|
||||
m_Channels = new ChannelInfo[a_Stream.ReadInt32()];
|
||||
m_Channels = new ChannelInfo[reader.ReadInt32()];
|
||||
for (int c = 0; c < m_Channels.Length; c++)
|
||||
{
|
||||
m_Channels[c] = new ChannelInfo();
|
||||
m_Channels[c].stream = a_Stream.ReadByte();
|
||||
m_Channels[c].offset = a_Stream.ReadByte();
|
||||
m_Channels[c].format = a_Stream.ReadByte();
|
||||
m_Channels[c].dimension = a_Stream.ReadByte();
|
||||
m_Channels[c].stream = reader.ReadByte();
|
||||
m_Channels[c].offset = reader.ReadByte();
|
||||
m_Channels[c].format = reader.ReadByte();
|
||||
m_Channels[c].dimension = reader.ReadByte();
|
||||
|
||||
//calculate stride for Unity 5
|
||||
//calculate stride for version 5
|
||||
//singleStreamStride += m_Channels[c].dimension * (4 / (int)Math.Pow(2, m_Channels[c].format));
|
||||
|
||||
if (m_Channels[c].stream >= streamCount) { streamCount = m_Channels[c].stream + 1; }
|
||||
@@ -636,23 +722,23 @@ namespace Unity_Studio
|
||||
|
||||
if (version[0] < 5)
|
||||
{
|
||||
m_Streams = new StreamInfo[a_Stream.ReadInt32()];
|
||||
m_Streams = new StreamInfo[reader.ReadInt32()];
|
||||
for (int s = 0; s < m_Streams.Length; s++)
|
||||
{
|
||||
m_Streams[s] = new StreamInfo();
|
||||
m_Streams[s].channelMask = new BitArray(new int[1] { a_Stream.ReadInt32() });
|
||||
m_Streams[s].offset = a_Stream.ReadInt32();
|
||||
m_Streams[s].stride = a_Stream.ReadByte();
|
||||
m_Streams[s].dividerOp = a_Stream.ReadByte();
|
||||
m_Streams[s].frequency = a_Stream.ReadUInt16();
|
||||
m_Streams[s].channelMask = new BitArray(new int[1] { reader.ReadInt32() });
|
||||
m_Streams[s].offset = reader.ReadInt32();
|
||||
m_Streams[s].stride = reader.ReadByte();
|
||||
m_Streams[s].dividerOp = reader.ReadByte();
|
||||
m_Streams[s].frequency = reader.ReadUInt16();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
//actual Vertex Buffer
|
||||
byte[] m_DataSize = new byte[a_Stream.ReadInt32()];
|
||||
a_Stream.Read(m_DataSize, 0, m_DataSize.Length);
|
||||
byte[] m_DataSize = new byte[reader.ReadInt32()];
|
||||
reader.Read(m_DataSize, 0, m_DataSize.Length);
|
||||
|
||||
if (version[0] >= 5) //create streams
|
||||
{
|
||||
@@ -713,7 +799,7 @@ namespace Unity_Studio
|
||||
//in the future, try to use only m_CurrentChannels
|
||||
if ((version[0] < 5 && m_Stream.channelMask.Get(b)) || (version[0] >= 5 && m_CurrentChannels.Get(b)))
|
||||
{
|
||||
// in Unity 4.x the colors channel has 1 dimension, as in 1 color with 4 components
|
||||
// in version 4.x the colors channel has 1 dimension, as in 1 color with 4 components
|
||||
if (b == 2 && m_Channel.format == 2) { m_Channel.dimension = 4; }
|
||||
|
||||
componentByteSize = 4 / (int)Math.Pow(2, m_Channel.format);
|
||||
@@ -778,7 +864,7 @@ namespace Unity_Studio
|
||||
foreach (var m_Stream in m_Streams)
|
||||
{
|
||||
//a stream may have multiple vertex components but without channels there are no offsets, so I assume all vertex properties are in order
|
||||
//Unity 3.5.x only uses floats, and that's probably why channels were introduced in Unity 4
|
||||
//version 3.5.x only uses floats, and that's probably why channels were introduced in version 4
|
||||
|
||||
ChannelInfo m_Channel = new ChannelInfo();//create my own channel so I can use the same methods
|
||||
m_Channel.offset = 0;
|
||||
@@ -853,14 +939,14 @@ namespace Unity_Studio
|
||||
|
||||
#region m_Vertices
|
||||
PackedBitVector m_Vertices_Packed = new PackedBitVector();
|
||||
m_Vertices_Packed.m_NumItems = a_Stream.ReadInt32();
|
||||
m_Vertices_Packed.m_Range = a_Stream.ReadSingle();
|
||||
m_Vertices_Packed.m_Start = a_Stream.ReadSingle();
|
||||
m_Vertices_Packed.m_Data = new byte[a_Stream.ReadInt32()];
|
||||
a_Stream.Read(m_Vertices_Packed.m_Data, 0, m_Vertices_Packed.m_Data.Length);
|
||||
a_Stream.AlignStream(4);
|
||||
m_Vertices_Packed.m_BitSize = a_Stream.ReadByte();
|
||||
a_Stream.Position += 3; //4 byte alignment
|
||||
m_Vertices_Packed.m_NumItems = reader.ReadInt32();
|
||||
m_Vertices_Packed.m_Range = reader.ReadSingle();
|
||||
m_Vertices_Packed.m_Start = reader.ReadSingle();
|
||||
m_Vertices_Packed.m_Data = new byte[reader.ReadInt32()];
|
||||
reader.Read(m_Vertices_Packed.m_Data, 0, m_Vertices_Packed.m_Data.Length);
|
||||
reader.AlignStream(4);
|
||||
m_Vertices_Packed.m_BitSize = reader.ReadByte();
|
||||
reader.Position += 3; //4 byte alignment
|
||||
|
||||
if (m_Vertices_Packed.m_NumItems > 0)
|
||||
{
|
||||
@@ -878,14 +964,14 @@ namespace Unity_Studio
|
||||
|
||||
#region m_UV
|
||||
PackedBitVector m_UV_Packed = new PackedBitVector(); //contains all channels
|
||||
m_UV_Packed.m_NumItems = a_Stream.ReadInt32();
|
||||
m_UV_Packed.m_Range = a_Stream.ReadSingle();
|
||||
m_UV_Packed.m_Start = a_Stream.ReadSingle();
|
||||
m_UV_Packed.m_Data = new byte[a_Stream.ReadInt32()];
|
||||
a_Stream.Read(m_UV_Packed.m_Data, 0, m_UV_Packed.m_Data.Length);
|
||||
a_Stream.AlignStream(4);
|
||||
m_UV_Packed.m_BitSize = a_Stream.ReadByte();
|
||||
a_Stream.Position += 3; //4 byte alignment
|
||||
m_UV_Packed.m_NumItems = reader.ReadInt32();
|
||||
m_UV_Packed.m_Range = reader.ReadSingle();
|
||||
m_UV_Packed.m_Start = reader.ReadSingle();
|
||||
m_UV_Packed.m_Data = new byte[reader.ReadInt32()];
|
||||
reader.Read(m_UV_Packed.m_Data, 0, m_UV_Packed.m_Data.Length);
|
||||
reader.AlignStream(4);
|
||||
m_UV_Packed.m_BitSize = reader.ReadByte();
|
||||
reader.Position += 3; //4 byte alignment
|
||||
|
||||
if (m_UV_Packed.m_NumItems > 0 && (bool)Properties.Settings.Default["exportUVs"])
|
||||
{
|
||||
@@ -933,14 +1019,14 @@ namespace Unity_Studio
|
||||
if (version[0] < 5)
|
||||
{
|
||||
PackedBitVector m_BindPoses_Packed = new PackedBitVector();
|
||||
m_BindPoses_Packed.m_NumItems = a_Stream.ReadInt32();
|
||||
m_BindPoses_Packed.m_Range = a_Stream.ReadSingle();
|
||||
m_BindPoses_Packed.m_Start = a_Stream.ReadSingle();
|
||||
m_BindPoses_Packed.m_Data = new byte[a_Stream.ReadInt32()];
|
||||
a_Stream.Read(m_BindPoses_Packed.m_Data, 0, m_BindPoses_Packed.m_Data.Length);
|
||||
a_Stream.AlignStream(4);
|
||||
m_BindPoses_Packed.m_BitSize = a_Stream.ReadByte();
|
||||
a_Stream.Position += 3; //4 byte alignment
|
||||
m_BindPoses_Packed.m_NumItems = reader.ReadInt32();
|
||||
m_BindPoses_Packed.m_Range = reader.ReadSingle();
|
||||
m_BindPoses_Packed.m_Start = reader.ReadSingle();
|
||||
m_BindPoses_Packed.m_Data = new byte[reader.ReadInt32()];
|
||||
reader.Read(m_BindPoses_Packed.m_Data, 0, m_BindPoses_Packed.m_Data.Length);
|
||||
reader.AlignStream(4);
|
||||
m_BindPoses_Packed.m_BitSize = reader.ReadByte();
|
||||
reader.Position += 3; //4 byte alignment
|
||||
|
||||
if (m_BindPoses_Packed.m_NumItems > 0 && (bool)Properties.Settings.Default["exportDeformers"])
|
||||
{
|
||||
@@ -966,41 +1052,41 @@ namespace Unity_Studio
|
||||
#endregion
|
||||
|
||||
PackedBitVector m_Normals_Packed = new PackedBitVector();
|
||||
m_Normals_Packed.m_NumItems = a_Stream.ReadInt32();
|
||||
m_Normals_Packed.m_Range = a_Stream.ReadSingle();
|
||||
m_Normals_Packed.m_Start = a_Stream.ReadSingle();
|
||||
m_Normals_Packed.m_Data = new byte[a_Stream.ReadInt32()];
|
||||
a_Stream.Read(m_Normals_Packed.m_Data, 0, m_Normals_Packed.m_Data.Length);
|
||||
a_Stream.AlignStream(4);
|
||||
m_Normals_Packed.m_BitSize = a_Stream.ReadByte();
|
||||
a_Stream.Position += 3; //4 byte alignment
|
||||
m_Normals_Packed.m_NumItems = reader.ReadInt32();
|
||||
m_Normals_Packed.m_Range = reader.ReadSingle();
|
||||
m_Normals_Packed.m_Start = reader.ReadSingle();
|
||||
m_Normals_Packed.m_Data = new byte[reader.ReadInt32()];
|
||||
reader.Read(m_Normals_Packed.m_Data, 0, m_Normals_Packed.m_Data.Length);
|
||||
reader.AlignStream(4);
|
||||
m_Normals_Packed.m_BitSize = reader.ReadByte();
|
||||
reader.Position += 3; //4 byte alignment
|
||||
|
||||
PackedBitVector m_Tangents_Packed = new PackedBitVector();
|
||||
m_Tangents_Packed.m_NumItems = a_Stream.ReadInt32();
|
||||
m_Tangents_Packed.m_Range = a_Stream.ReadSingle();
|
||||
m_Tangents_Packed.m_Start = a_Stream.ReadSingle();
|
||||
m_Tangents_Packed.m_Data = new byte[a_Stream.ReadInt32()];
|
||||
a_Stream.Read(m_Tangents_Packed.m_Data, 0, m_Tangents_Packed.m_Data.Length);
|
||||
a_Stream.AlignStream(4);
|
||||
m_Tangents_Packed.m_BitSize = a_Stream.ReadByte();
|
||||
a_Stream.Position += 3; //4 byte alignment
|
||||
m_Tangents_Packed.m_NumItems = reader.ReadInt32();
|
||||
m_Tangents_Packed.m_Range = reader.ReadSingle();
|
||||
m_Tangents_Packed.m_Start = reader.ReadSingle();
|
||||
m_Tangents_Packed.m_Data = new byte[reader.ReadInt32()];
|
||||
reader.Read(m_Tangents_Packed.m_Data, 0, m_Tangents_Packed.m_Data.Length);
|
||||
reader.AlignStream(4);
|
||||
m_Tangents_Packed.m_BitSize = reader.ReadByte();
|
||||
reader.Position += 3; //4 byte alignment
|
||||
|
||||
PackedBitVector m_Weights = new PackedBitVector();
|
||||
m_Weights.m_NumItems = a_Stream.ReadInt32();
|
||||
m_Weights.m_Data = new byte[a_Stream.ReadInt32()];
|
||||
a_Stream.Read(m_Weights.m_Data, 0, m_Weights.m_Data.Length);
|
||||
a_Stream.AlignStream(4);
|
||||
m_Weights.m_BitSize = a_Stream.ReadByte();
|
||||
a_Stream.Position += 3; //4 byte alignment
|
||||
m_Weights.m_NumItems = reader.ReadInt32();
|
||||
m_Weights.m_Data = new byte[reader.ReadInt32()];
|
||||
reader.Read(m_Weights.m_Data, 0, m_Weights.m_Data.Length);
|
||||
reader.AlignStream(4);
|
||||
m_Weights.m_BitSize = reader.ReadByte();
|
||||
reader.Position += 3; //4 byte alignment
|
||||
|
||||
#region m_Normals
|
||||
PackedBitVector m_NormalSigns_packed = new PackedBitVector();
|
||||
m_NormalSigns_packed.m_NumItems = a_Stream.ReadInt32();
|
||||
m_NormalSigns_packed.m_Data = new byte[a_Stream.ReadInt32()];
|
||||
a_Stream.Read(m_NormalSigns_packed.m_Data, 0, m_NormalSigns_packed.m_Data.Length);
|
||||
a_Stream.AlignStream(4);
|
||||
m_NormalSigns_packed.m_BitSize = a_Stream.ReadByte();
|
||||
a_Stream.Position += 3; //4 byte alignment
|
||||
m_NormalSigns_packed.m_NumItems = reader.ReadInt32();
|
||||
m_NormalSigns_packed.m_Data = new byte[reader.ReadInt32()];
|
||||
reader.Read(m_NormalSigns_packed.m_Data, 0, m_NormalSigns_packed.m_Data.Length);
|
||||
reader.AlignStream(4);
|
||||
m_NormalSigns_packed.m_BitSize = reader.ReadByte();
|
||||
reader.Position += 3; //4 byte alignment
|
||||
|
||||
if (m_Normals_Packed.m_NumItems > 0 && (bool)Properties.Settings.Default["exportNormals"])
|
||||
{
|
||||
@@ -1021,12 +1107,12 @@ namespace Unity_Studio
|
||||
|
||||
#region m_Tangents
|
||||
PackedBitVector m_TangentSigns_packed = new PackedBitVector();
|
||||
m_TangentSigns_packed.m_NumItems = a_Stream.ReadInt32();
|
||||
m_TangentSigns_packed.m_Data = new byte[a_Stream.ReadInt32()];
|
||||
a_Stream.Read(m_TangentSigns_packed.m_Data, 0, m_TangentSigns_packed.m_Data.Length);
|
||||
a_Stream.AlignStream(4);
|
||||
m_TangentSigns_packed.m_BitSize = a_Stream.ReadByte();
|
||||
a_Stream.Position += 3; //4 byte alignment
|
||||
m_TangentSigns_packed.m_NumItems = reader.ReadInt32();
|
||||
m_TangentSigns_packed.m_Data = new byte[reader.ReadInt32()];
|
||||
reader.Read(m_TangentSigns_packed.m_Data, 0, m_TangentSigns_packed.m_Data.Length);
|
||||
reader.AlignStream(4);
|
||||
m_TangentSigns_packed.m_BitSize = reader.ReadByte();
|
||||
reader.Position += 3; //4 byte alignment
|
||||
|
||||
if (m_Tangents_Packed.m_NumItems > 0 && (bool)Properties.Settings.Default["exportTangents"])
|
||||
{
|
||||
@@ -1049,14 +1135,14 @@ namespace Unity_Studio
|
||||
if (version[0] >= 5)
|
||||
{
|
||||
PackedBitVector m_FloatColors = new PackedBitVector();
|
||||
m_FloatColors.m_NumItems = a_Stream.ReadInt32();
|
||||
m_FloatColors.m_Range = a_Stream.ReadSingle();
|
||||
m_FloatColors.m_Start = a_Stream.ReadSingle();
|
||||
m_FloatColors.m_Data = new byte[a_Stream.ReadInt32()];
|
||||
a_Stream.Read(m_FloatColors.m_Data, 0, m_FloatColors.m_Data.Length);
|
||||
a_Stream.AlignStream(4);
|
||||
m_FloatColors.m_BitSize = a_Stream.ReadByte();
|
||||
a_Stream.Position += 3; //4 byte alignment
|
||||
m_FloatColors.m_NumItems = reader.ReadInt32();
|
||||
m_FloatColors.m_Range = reader.ReadSingle();
|
||||
m_FloatColors.m_Start = reader.ReadSingle();
|
||||
m_FloatColors.m_Data = new byte[reader.ReadInt32()];
|
||||
reader.Read(m_FloatColors.m_Data, 0, m_FloatColors.m_Data.Length);
|
||||
reader.AlignStream(4);
|
||||
m_FloatColors.m_BitSize = reader.ReadByte();
|
||||
reader.Position += 3; //4 byte alignment
|
||||
|
||||
if (m_FloatColors.m_NumItems > 0 && (bool)Properties.Settings.Default["exportColors"])
|
||||
{
|
||||
@@ -1076,12 +1162,12 @@ namespace Unity_Studio
|
||||
|
||||
#region m_Skin
|
||||
PackedBitVector m_BoneIndices = new PackedBitVector();
|
||||
m_BoneIndices.m_NumItems = a_Stream.ReadInt32();
|
||||
m_BoneIndices.m_Data = new byte[a_Stream.ReadInt32()];
|
||||
a_Stream.Read(m_BoneIndices.m_Data, 0, m_BoneIndices.m_Data.Length);
|
||||
a_Stream.AlignStream(4);
|
||||
m_BoneIndices.m_BitSize = a_Stream.ReadByte();
|
||||
a_Stream.Position += 3; //4 byte alignment
|
||||
m_BoneIndices.m_NumItems = reader.ReadInt32();
|
||||
m_BoneIndices.m_Data = new byte[reader.ReadInt32()];
|
||||
reader.Read(m_BoneIndices.m_Data, 0, m_BoneIndices.m_Data.Length);
|
||||
reader.AlignStream(4);
|
||||
m_BoneIndices.m_BitSize = reader.ReadByte();
|
||||
reader.Position += 3; //4 byte alignment
|
||||
|
||||
if (m_BoneIndices.m_NumItems > 0 && (bool)Properties.Settings.Default["exportDeformers"])
|
||||
{
|
||||
@@ -1163,12 +1249,12 @@ namespace Unity_Studio
|
||||
#endregion
|
||||
|
||||
PackedBitVector m_Triangles = new PackedBitVector();
|
||||
m_Triangles.m_NumItems = a_Stream.ReadInt32();
|
||||
m_Triangles.m_Data = new byte[a_Stream.ReadInt32()];
|
||||
a_Stream.Read(m_Triangles.m_Data, 0, m_Triangles.m_Data.Length);
|
||||
a_Stream.AlignStream(4);
|
||||
m_Triangles.m_BitSize = a_Stream.ReadByte();
|
||||
a_Stream.Position += 3; //4 byte alignment
|
||||
m_Triangles.m_NumItems = reader.ReadInt32();
|
||||
m_Triangles.m_Data = new byte[reader.ReadInt32()];
|
||||
reader.Read(m_Triangles.m_Data, 0, m_Triangles.m_Data.Length);
|
||||
reader.AlignStream(4);
|
||||
m_Triangles.m_BitSize = reader.ReadByte();
|
||||
reader.Position += 3; //4 byte alignment
|
||||
|
||||
if (m_Triangles.m_NumItems > 0) { m_IndexBuffer = UnpackBitVector(m_Triangles); }
|
||||
}
|
||||
@@ -1177,14 +1263,14 @@ namespace Unity_Studio
|
||||
#region Colors & Collision triangles for 3.4.2 and earlier
|
||||
if (version[0] <= 2 || (version[0] == 3 && version[1] <= 4)) //
|
||||
{
|
||||
a_Stream.Position += 24; //Axis-Aligned Bounding Box
|
||||
int m_Colors_size = a_Stream.ReadInt32();
|
||||
reader.Position += 24; //Axis-Aligned Bounding Box
|
||||
int m_Colors_size = reader.ReadInt32();
|
||||
m_Colors = new float[m_Colors_size * 4];
|
||||
for (int v = 0; v < m_Colors_size * 4; v++) { m_Colors[v] = (float)(a_Stream.ReadByte()) / 0xFF; }
|
||||
for (int v = 0; v < m_Colors_size * 4; v++) { m_Colors[v] = (float)(reader.ReadByte()) / 0xFF; }
|
||||
|
||||
int m_CollisionTriangles_size = a_Stream.ReadInt32();
|
||||
a_Stream.Position += m_CollisionTriangles_size * 4; //UInt32 indices
|
||||
int m_CollisionVertexCount = a_Stream.ReadInt32();
|
||||
int m_CollisionTriangles_size = reader.ReadInt32();
|
||||
reader.Position += m_CollisionTriangles_size * 4; //UInt32 indices
|
||||
int m_CollisionVertexCount = reader.ReadInt32();
|
||||
}
|
||||
#endregion
|
||||
#region Compressed colors & Local AABB for 3.5.0 to 4.x.x
|
||||
@@ -1193,12 +1279,12 @@ namespace Unity_Studio
|
||||
if (version[0] < 5)
|
||||
{
|
||||
PackedBitVector m_Colors_Packed = new PackedBitVector();
|
||||
m_Colors_Packed.m_NumItems = a_Stream.ReadInt32();
|
||||
m_Colors_Packed.m_Data = new byte[a_Stream.ReadInt32()];
|
||||
a_Stream.Read(m_Colors_Packed.m_Data, 0, m_Colors_Packed.m_Data.Length);
|
||||
a_Stream.AlignStream(4);
|
||||
m_Colors_Packed.m_BitSize = a_Stream.ReadByte();
|
||||
a_Stream.Position += 3; //4 byte alignment
|
||||
m_Colors_Packed.m_NumItems = reader.ReadInt32();
|
||||
m_Colors_Packed.m_Data = new byte[reader.ReadInt32()];
|
||||
reader.Read(m_Colors_Packed.m_Data, 0, m_Colors_Packed.m_Data.Length);
|
||||
reader.AlignStream(4);
|
||||
m_Colors_Packed.m_BitSize = reader.ReadByte();
|
||||
reader.Position += 3; //4 byte alignment
|
||||
|
||||
if (m_Colors_Packed.m_NumItems > 0)
|
||||
{
|
||||
@@ -1224,13 +1310,13 @@ namespace Unity_Studio
|
||||
}
|
||||
}
|
||||
}
|
||||
else { uint m_UVInfo = a_Stream.ReadUInt32(); }
|
||||
else { uint m_UVInfo = reader.ReadUInt32(); }
|
||||
|
||||
a_Stream.Position += 24; //Axis-Aligned Bounding Box
|
||||
reader.Position += 24; //Axis-Aligned Bounding Box
|
||||
}
|
||||
#endregion
|
||||
|
||||
int m_MeshUsageFlags = a_Stream.ReadInt32();
|
||||
int m_MeshUsageFlags = reader.ReadInt32();
|
||||
|
||||
if (version[0] >= 5)
|
||||
{
|
||||
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Unity_Studio
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class MeshFilter
|
||||
{
|
||||
@@ -14,12 +14,11 @@ namespace Unity_Studio
|
||||
public MeshFilter(AssetPreloadData preloadData)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var a_Stream = preloadData.sourceFile.a_Stream;
|
||||
a_Stream.Position = preloadData.Offset;
|
||||
var reader = preloadData.InitReader();
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
{
|
||||
uint m_ObjectHideFlags = a_Stream.ReadUInt32();
|
||||
uint m_ObjectHideFlags = reader.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
}
|
||||
64
AssetStudio/Classes/MeshRenderer.cs
Normal file
64
AssetStudio/Classes/MeshRenderer.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class MeshRenderer
|
||||
{
|
||||
public PPtr m_GameObject;
|
||||
public bool m_Enabled;
|
||||
public byte m_CastShadows; //bool prior to version 5
|
||||
public bool m_ReceiveShadows;
|
||||
public ushort m_LightmapIndex;
|
||||
public ushort m_LightmapIndexDynamic;
|
||||
public PPtr[] m_Materials;
|
||||
|
||||
protected MeshRenderer() { }
|
||||
|
||||
public MeshRenderer(AssetPreloadData preloadData)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var reader = preloadData.InitReader();
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
{
|
||||
uint m_ObjectHideFlags = reader.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
m_GameObject = sourceFile.ReadPPtr();
|
||||
|
||||
if (sourceFile.version[0] < 5)
|
||||
{
|
||||
m_Enabled = reader.ReadBoolean();
|
||||
m_CastShadows = reader.ReadByte();
|
||||
m_ReceiveShadows = reader.ReadBoolean();
|
||||
m_LightmapIndex = reader.ReadByte();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Enabled = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
m_CastShadows = reader.ReadByte();
|
||||
m_ReceiveShadows = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
|
||||
m_LightmapIndex = reader.ReadUInt16();
|
||||
m_LightmapIndexDynamic = reader.ReadUInt16();
|
||||
}
|
||||
|
||||
if (sourceFile.version[0] >= 3) { reader.Position += 16; } //Vector4f m_LightmapTilingOffset
|
||||
if (sourceFile.version[0] >= 5) { reader.Position += 16; } //Vector4f m_LightmapTilingOffsetDynamic
|
||||
|
||||
m_Materials = new PPtr[reader.ReadInt32()];
|
||||
for (int m = 0; m < m_Materials.Length; m++)
|
||||
{
|
||||
m_Materials[m] = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Unity_Studio
|
||||
namespace AssetStudio
|
||||
{
|
||||
class MonoBehaviour
|
||||
{
|
||||
@@ -12,14 +12,13 @@ namespace Unity_Studio
|
||||
public MonoBehaviour(AssetPreloadData preloadData, bool readSwitch)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var a_Stream = preloadData.sourceFile.a_Stream;
|
||||
a_Stream.Position = preloadData.Offset;
|
||||
var reader = preloadData.InitReader();
|
||||
|
||||
var m_GameObject = sourceFile.ReadPPtr();
|
||||
var m_Enabled = a_Stream.ReadByte();
|
||||
a_Stream.AlignStream(4);
|
||||
var m_Enabled = reader.ReadByte();
|
||||
reader.AlignStream(4);
|
||||
var m_Script = sourceFile.ReadPPtr();
|
||||
var m_Name = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
var m_Name = reader.ReadAlignedString();
|
||||
if (readSwitch)
|
||||
{
|
||||
if ((serializedText = preloadData.ViewStruct()) == null)
|
||||
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Unity_Studio
|
||||
namespace AssetStudio
|
||||
{
|
||||
class MovieTexture
|
||||
{
|
||||
@@ -13,19 +13,18 @@ namespace Unity_Studio
|
||||
public MovieTexture(AssetPreloadData preloadData, bool readSwitch)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var a_Stream = preloadData.sourceFile.a_Stream;
|
||||
a_Stream.Position = preloadData.Offset;
|
||||
var reader = preloadData.InitReader();
|
||||
|
||||
m_Name = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
m_Name = reader.ReadAlignedString();
|
||||
if (readSwitch)
|
||||
{
|
||||
var m_Loop = a_Stream.ReadBoolean();
|
||||
a_Stream.AlignStream(4);
|
||||
var m_Loop = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
//PPtr<AudioClip>
|
||||
sourceFile.ReadPPtr();
|
||||
var size = a_Stream.ReadInt32();
|
||||
m_MovieData = a_Stream.ReadBytes(size);
|
||||
var m_ColorSpace = a_Stream.ReadInt32();
|
||||
var size = reader.ReadInt32();
|
||||
m_MovieData = reader.ReadBytes(size);
|
||||
var m_ColorSpace = reader.ReadInt32();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Unity_Studio
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class PlayerSettings
|
||||
{
|
||||
@@ -13,45 +13,44 @@ namespace Unity_Studio
|
||||
public PlayerSettings(AssetPreloadData preloadData)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var a_Stream = preloadData.sourceFile.a_Stream;
|
||||
a_Stream.Position = preloadData.Offset;
|
||||
var reader = preloadData.InitReader();
|
||||
|
||||
|
||||
if ((sourceFile.version[0] == 5 && sourceFile.version[1] >= 4) || sourceFile.version[0] > 5)//5.4.0 nad up
|
||||
{
|
||||
//productGUID
|
||||
a_Stream.ReadInt32();
|
||||
a_Stream.ReadInt32();
|
||||
a_Stream.ReadInt32();
|
||||
a_Stream.ReadInt32();
|
||||
reader.ReadInt32();
|
||||
reader.ReadInt32();
|
||||
reader.ReadInt32();
|
||||
reader.ReadInt32();
|
||||
}
|
||||
if (sourceFile.version[0] >= 3)
|
||||
{
|
||||
if (sourceFile.version[0] == 3 && sourceFile.version[1] < 2) { string AndroidLicensePublicKey = a_Stream.ReadAlignedString(a_Stream.ReadInt32()); }
|
||||
else { bool AndroidProfiler = a_Stream.ReadBoolean(); a_Stream.AlignStream(4); }
|
||||
if (sourceFile.version[0] == 3 && sourceFile.version[1] < 2) { string AndroidLicensePublicKey = reader.ReadAlignedString(); }
|
||||
else { bool AndroidProfiler = reader.ReadBoolean(); reader.AlignStream(4); }
|
||||
|
||||
int defaultScreenOrientation = a_Stream.ReadInt32();
|
||||
int targetDevice = a_Stream.ReadInt32();
|
||||
int defaultScreenOrientation = reader.ReadInt32();
|
||||
int targetDevice = reader.ReadInt32();
|
||||
|
||||
if (sourceFile.version[0] < 5 || (sourceFile.version[0] == 5 && sourceFile.version[1] < 1))
|
||||
{ int targetGlesGraphics = a_Stream.ReadInt32(); }
|
||||
{ int targetGlesGraphics = reader.ReadInt32(); }
|
||||
|
||||
if ((sourceFile.version[0] == 5 && sourceFile.version[1] < 1) || (sourceFile.version[0] == 4 && sourceFile.version[1] == 6 && sourceFile.version[2] >= 3))
|
||||
{ int targetIOSGraphics = a_Stream.ReadInt32(); }
|
||||
{ int targetIOSGraphics = reader.ReadInt32(); }
|
||||
|
||||
if (sourceFile.version[0] >= 5 || sourceFile.version[0] == 5 && (sourceFile.version[1] > 2 || (sourceFile.version[1] == 2 && sourceFile.version[2] >= 1)))
|
||||
{ bool useOnDemandResources = a_Stream.ReadBoolean(); a_Stream.AlignStream(4); }
|
||||
{ bool useOnDemandResources = reader.ReadBoolean(); reader.AlignStream(4); }
|
||||
|
||||
if (sourceFile.version[0] < 5 || (sourceFile.version[0] == 5 && sourceFile.version[1] < 3))
|
||||
{ int targetResolution = a_Stream.ReadInt32(); }
|
||||
{ int targetResolution = reader.ReadInt32(); }
|
||||
|
||||
if (sourceFile.version[0] == 3 && sourceFile.version[1] <= 1) { bool OverrideIPodMusic = a_Stream.ReadBoolean(); a_Stream.AlignStream(4); }
|
||||
if (sourceFile.version[0] == 3 && sourceFile.version[1] <= 1) { bool OverrideIPodMusic = reader.ReadBoolean(); reader.AlignStream(4); }
|
||||
else if (sourceFile.version[0] == 3 && sourceFile.version[1] <= 4) { }
|
||||
else { int accelerometerFrequency = a_Stream.ReadInt32(); }//3.5.0 and up
|
||||
else { int accelerometerFrequency = reader.ReadInt32(); }//3.5.0 and up
|
||||
}
|
||||
//fail in Unity 5 beta
|
||||
companyName = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
productName = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
//fail in version 5 beta
|
||||
companyName = reader.ReadAlignedString();
|
||||
productName = reader.ReadAlignedString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Unity_Studio
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class RectTransform
|
||||
{
|
||||
@@ -6,7 +6,7 @@ using System.Text;
|
||||
using System.Web.Script.Serialization;
|
||||
using Lz4;
|
||||
|
||||
namespace Unity_Studio
|
||||
namespace AssetStudio
|
||||
{
|
||||
class Shader
|
||||
{
|
||||
@@ -16,17 +16,16 @@ namespace Unity_Studio
|
||||
public Shader(AssetPreloadData preloadData, bool readSwitch)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var a_Stream = preloadData.sourceFile.a_Stream;
|
||||
a_Stream.Position = preloadData.Offset;
|
||||
var reader = preloadData.InitReader();
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
{
|
||||
uint m_ObjectHideFlags = a_Stream.ReadUInt32();
|
||||
uint m_ObjectHideFlags = reader.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
m_Name = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
m_Name = reader.ReadAlignedString();
|
||||
|
||||
if (readSwitch)
|
||||
{
|
||||
@@ -43,29 +42,27 @@ namespace Unity_Studio
|
||||
}
|
||||
else
|
||||
{
|
||||
a_Stream.Position = preloadData.Offset;
|
||||
reader.Position = preloadData.Offset;
|
||||
var sb = new StringBuilder();
|
||||
var members = new JavaScriptSerializer().Deserialize<List<ClassMember>>(str);
|
||||
ClassStructHelper.ReadClassStruct(sb, members, a_Stream);
|
||||
ClassStructHelper.ReadClassStruct(sb, members, reader);
|
||||
m_Script = Encoding.UTF8.GetBytes(sb.ToString());
|
||||
//m_Script = ReadSerializedShader(members, a_Stream);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Script = a_Stream.ReadBytes(a_Stream.ReadInt32());
|
||||
m_Script = reader.ReadBytes(reader.ReadInt32());
|
||||
if (sourceFile.version[0] == 5 && sourceFile.version[1] >= 3) //5.3 - 5.4
|
||||
{
|
||||
a_Stream.AlignStream(4);
|
||||
a_Stream.ReadAlignedString(a_Stream.ReadInt32());//m_PathName
|
||||
var decompressedSize = a_Stream.ReadUInt32();
|
||||
var m_SubProgramBlob = a_Stream.ReadBytes(a_Stream.ReadInt32());
|
||||
reader.AlignStream(4);
|
||||
reader.ReadAlignedString();//m_PathName
|
||||
var decompressedSize = reader.ReadUInt32();
|
||||
var m_SubProgramBlob = reader.ReadBytes(reader.ReadInt32());
|
||||
var decompressedBytes = new byte[decompressedSize];
|
||||
using (var mstream = new MemoryStream(m_SubProgramBlob))
|
||||
using (var decoder = new Lz4DecoderStream(new MemoryStream(m_SubProgramBlob)))
|
||||
{
|
||||
var decoder = new Lz4DecoderStream(mstream);
|
||||
decoder.Read(decompressedBytes, 0, (int)decompressedSize);
|
||||
decoder.Dispose();
|
||||
}
|
||||
m_Script = m_Script.Concat(decompressedBytes.ToArray()).ToArray();
|
||||
}
|
||||
@@ -3,30 +3,23 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Unity_Studio
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class SkinnedMeshRenderer
|
||||
public class SkinnedMeshRenderer : MeshRenderer
|
||||
{
|
||||
public PPtr m_GameObject;
|
||||
public bool m_Enabled;
|
||||
public byte m_CastShadows;
|
||||
public bool m_ReceiveShadows;
|
||||
public ushort m_LightmapIndex;
|
||||
public ushort m_LightmapIndexDynamic;
|
||||
public PPtr[] m_Materials;
|
||||
public PPtr m_Mesh;
|
||||
public PPtr[] m_Bones;
|
||||
public List<float> m_BlendShapeWeights;
|
||||
|
||||
public SkinnedMeshRenderer(AssetPreloadData preloadData)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var version = preloadData.sourceFile.version;
|
||||
var a_Stream = preloadData.sourceFile.a_Stream;
|
||||
a_Stream.Position = preloadData.Offset;
|
||||
var reader = preloadData.InitReader();
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
{
|
||||
uint m_ObjectHideFlags = a_Stream.ReadUInt32();
|
||||
uint m_ObjectHideFlags = reader.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
}
|
||||
@@ -34,27 +27,27 @@ namespace Unity_Studio
|
||||
m_GameObject = sourceFile.ReadPPtr();
|
||||
if (sourceFile.version[0] < 5)
|
||||
{
|
||||
m_Enabled = a_Stream.ReadBoolean();
|
||||
m_CastShadows = a_Stream.ReadByte();//bool
|
||||
m_ReceiveShadows = a_Stream.ReadBoolean();
|
||||
m_LightmapIndex = a_Stream.ReadByte();
|
||||
m_Enabled = reader.ReadBoolean();
|
||||
m_CastShadows = reader.ReadByte();//bool
|
||||
m_ReceiveShadows = reader.ReadBoolean();
|
||||
m_LightmapIndex = reader.ReadByte();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Enabled = a_Stream.ReadBoolean();
|
||||
a_Stream.AlignStream(4);
|
||||
m_CastShadows = a_Stream.ReadByte();
|
||||
m_ReceiveShadows = a_Stream.ReadBoolean();
|
||||
a_Stream.AlignStream(4);
|
||||
m_Enabled = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
m_CastShadows = reader.ReadByte();
|
||||
m_ReceiveShadows = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
|
||||
m_LightmapIndex = a_Stream.ReadUInt16();
|
||||
m_LightmapIndexDynamic = a_Stream.ReadUInt16();
|
||||
m_LightmapIndex = reader.ReadUInt16();
|
||||
m_LightmapIndexDynamic = reader.ReadUInt16();
|
||||
}
|
||||
|
||||
if (version[0] >= 3) { a_Stream.Position += 16; } //m_LightmapTilingOffset vector4d
|
||||
if (sourceFile.version[0] >= 5) { a_Stream.Position += 16; } //Vector4f m_LightmapTilingOffsetDynamic
|
||||
if (version[0] >= 3) { reader.Position += 16; } //m_LightmapTilingOffset vector4d
|
||||
if (sourceFile.version[0] >= 5) { reader.Position += 16; } //Vector4f m_LightmapTilingOffsetDynamic
|
||||
|
||||
m_Materials = new PPtr[a_Stream.ReadInt32()];
|
||||
m_Materials = new PPtr[reader.ReadInt32()];
|
||||
for (int m = 0; m < m_Materials.Length; m++)
|
||||
{
|
||||
m_Materials[m] = sourceFile.ReadPPtr();
|
||||
@@ -62,18 +55,18 @@ namespace Unity_Studio
|
||||
|
||||
if (version[0] < 3)
|
||||
{
|
||||
a_Stream.Position += 16;//m_LightmapTilingOffset vector4d
|
||||
reader.Position += 16;//m_LightmapTilingOffset vector4d
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((sourceFile.version[0] == 5 && sourceFile.version[1] >= 5) || sourceFile.version[0] > 5)//5.5.0 and up
|
||||
{
|
||||
a_Stream.Position += 4;//m_StaticBatchInfo
|
||||
reader.Position += 4;//m_StaticBatchInfo
|
||||
}
|
||||
else
|
||||
{
|
||||
int m_SubsetIndices_size = a_Stream.ReadInt32();
|
||||
a_Stream.Position += m_SubsetIndices_size * 4;
|
||||
int m_SubsetIndices_size = reader.ReadInt32();
|
||||
reader.Position += m_SubsetIndices_size * 4;
|
||||
}
|
||||
PPtr m_StaticBatchRoot = sourceFile.ReadPPtr();
|
||||
|
||||
@@ -84,37 +77,37 @@ namespace Unity_Studio
|
||||
}
|
||||
else if (version[0] >= 4 || (version[0] == 3 && version[1] >= 5))
|
||||
{
|
||||
bool m_UseLightProbes = a_Stream.ReadBoolean();
|
||||
a_Stream.Position += 3; //alignment
|
||||
if (version[0] == 5) { int m_ReflectionProbeUsage = a_Stream.ReadInt32(); }
|
||||
bool m_UseLightProbes = reader.ReadBoolean();
|
||||
reader.Position += 3; //alignment
|
||||
if (version[0] == 5) { int m_ReflectionProbeUsage = reader.ReadInt32(); }
|
||||
//did I ever check if the anchor is conditioned by the bool?
|
||||
PPtr m_LightProbeAnchor = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
if (version[0] >= 5 || (version[0] == 4 && version[1] >= 3))
|
||||
{
|
||||
if (version[0] == 4 && version[1] <= 3) { int m_SortingLayer = a_Stream.ReadInt16(); }
|
||||
else { int m_SortingLayer = a_Stream.ReadInt32(); }
|
||||
if (version[0] == 4 && version[1] <= 3) { int m_SortingLayer = reader.ReadInt16(); }
|
||||
else { int m_SortingLayer = reader.ReadInt32(); }
|
||||
|
||||
int m_SortingOrder = a_Stream.ReadInt16();
|
||||
a_Stream.AlignStream(4);
|
||||
int m_SortingOrder = reader.ReadInt16();
|
||||
reader.AlignStream(4);
|
||||
}
|
||||
}
|
||||
|
||||
int m_Quality = a_Stream.ReadInt32();
|
||||
bool m_UpdateWhenOffscreen = a_Stream.ReadBoolean();
|
||||
bool m_SkinNormals = a_Stream.ReadBoolean(); //3.1.0 and below
|
||||
a_Stream.Position += 2;
|
||||
int m_Quality = reader.ReadInt32();
|
||||
bool m_UpdateWhenOffscreen = reader.ReadBoolean();
|
||||
bool m_SkinNormals = reader.ReadBoolean(); //3.1.0 and below
|
||||
reader.Position += 2;
|
||||
|
||||
if (version[0] == 2 && version[1] < 6)
|
||||
{
|
||||
//this would be the only error if mainVersion is not read in time for a unity 2.x game
|
||||
//this would be the only error if mainVersion is not read in time for a version 2.x game
|
||||
PPtr m_DisableAnimationWhenOffscreen = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
m_Mesh = sourceFile.ReadPPtr();
|
||||
|
||||
m_Bones = new PPtr[a_Stream.ReadInt32()];
|
||||
m_Bones = new PPtr[reader.ReadInt32()];
|
||||
for (int b = 0; b < m_Bones.Length; b++)
|
||||
{
|
||||
m_Bones[b] = sourceFile.ReadPPtr();
|
||||
@@ -122,18 +115,22 @@ namespace Unity_Studio
|
||||
|
||||
if (version[0] < 3)
|
||||
{
|
||||
int m_BindPose = a_Stream.ReadInt32();
|
||||
a_Stream.Position += m_BindPose * 16 * 4;//Matrix4x4f
|
||||
int m_BindPose = reader.ReadInt32();
|
||||
reader.Position += m_BindPose * 16 * 4;//Matrix4x4f
|
||||
}
|
||||
else
|
||||
{
|
||||
if (version[0] > 4 || (version[0] == 4 && version[1] >= 3))
|
||||
if (version[0] > 4 || (version[0] == 4 && version[1] >= 3))//4.3 and up
|
||||
{
|
||||
int m_BlendShapeWeights = a_Stream.ReadInt32();
|
||||
a_Stream.Position += m_BlendShapeWeights * 4; //floats
|
||||
int numBSWeights = reader.ReadInt32();
|
||||
m_BlendShapeWeights = new List<float>(numBSWeights);
|
||||
for (int i = 0; i < numBSWeights; i++)
|
||||
{
|
||||
m_BlendShapeWeights.Add(reader.ReadSingle());
|
||||
}
|
||||
}
|
||||
|
||||
if (version[0] > 4 || (version[0] >= 3 && version[1] >= 5))
|
||||
/*if (version[0] > 4 || (version[0] >= 3 && version[1] >= 5))
|
||||
{
|
||||
PPtr m_RootBone = sourceFile.ReadPPtr();
|
||||
}
|
||||
@@ -141,10 +138,10 @@ namespace Unity_Studio
|
||||
if (version[0] > 4 || (version[0] == 3 && version[1] >= 4))
|
||||
{
|
||||
//AABB
|
||||
float[] m_Center = { a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() };
|
||||
float[] m_Extent = { a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() };
|
||||
bool m_DirtyAABB = a_Stream.ReadBoolean();
|
||||
}
|
||||
float[] m_Center = { reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() };
|
||||
float[] m_Extent = { reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() };
|
||||
bool m_DirtyAABB = reader.ReadBoolean();
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
169
AssetStudio/Classes/Sprite.cs
Normal file
169
AssetStudio/Classes/Sprite.cs
Normal file
@@ -0,0 +1,169 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
class Sprite
|
||||
{
|
||||
public string m_Name;
|
||||
public RectangleF m_Rect;
|
||||
public float m_PixelsToUnits;
|
||||
public PointF m_Pivot;
|
||||
public Guid first;
|
||||
public PPtr texture;
|
||||
public PPtr m_SpriteAtlas;
|
||||
public RectangleF textureRect;
|
||||
public PointF[][] m_PhysicsShape;
|
||||
|
||||
public Sprite(AssetPreloadData preloadData, bool readSwitch)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var reader = preloadData.InitReader();
|
||||
var version = sourceFile.version;
|
||||
|
||||
m_Name = reader.ReadAlignedString();
|
||||
if (readSwitch)
|
||||
{
|
||||
//Rectf m_Rect
|
||||
m_Rect = new RectangleF(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
|
||||
//Vector2f m_Offset
|
||||
reader.Position += 8;
|
||||
if (version[0] > 4 || (version[0] == 4 && version[1] >= 5)) //4.5 and up
|
||||
{
|
||||
//Vector4f m_Border
|
||||
reader.Position += 16;
|
||||
}
|
||||
|
||||
m_PixelsToUnits = reader.ReadSingle();
|
||||
if (version[0] > 5
|
||||
|| (version[0] == 5 && version[1] > 4)
|
||||
|| (version[0] == 5 && version[1] == 4 && version[2] >= 2)) //5.4.2 and up
|
||||
{
|
||||
//Vector2f m_Pivot
|
||||
m_Pivot = new PointF(reader.ReadSingle(), reader.ReadSingle());
|
||||
}
|
||||
|
||||
var m_Extrude = reader.ReadUInt32();
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 3)) //5.3 and up TODO need more test
|
||||
{
|
||||
var m_IsPolygon = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
}
|
||||
|
||||
if (version[0] >= 2017) //2017 and up
|
||||
{
|
||||
//pair m_RenderDataKey
|
||||
first = new Guid(reader.ReadBytes(16));
|
||||
var second = reader.ReadInt64();
|
||||
//vector m_AtlasTags
|
||||
var size = reader.ReadInt32();
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
var data = reader.ReadAlignedString();
|
||||
}
|
||||
|
||||
//PPtr<SpriteAtlas> m_SpriteAtlas
|
||||
m_SpriteAtlas = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
//SpriteRenderData m_RD
|
||||
// PPtr<Texture2D> texture
|
||||
texture = sourceFile.ReadPPtr();
|
||||
// PPtr<Texture2D> alphaTexture
|
||||
if (version[0] >= 5) //5.0 and up
|
||||
{
|
||||
var alphaTexture = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 6)) //5.6 and up
|
||||
{
|
||||
// vector m_SubMeshes
|
||||
var size = reader.ReadInt32();
|
||||
// SubMesh data
|
||||
if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 3)) //2017.3 and up
|
||||
{
|
||||
reader.Position += 48 * size;
|
||||
}
|
||||
else
|
||||
{
|
||||
reader.Position += 44 * size;
|
||||
}
|
||||
|
||||
// vector m_IndexBuffer
|
||||
size = reader.ReadInt32();
|
||||
reader.Position += size; //UInt8 data
|
||||
reader.AlignStream(4);
|
||||
// VertexData m_VertexData
|
||||
var m_CurrentChannels = reader.ReadInt32();
|
||||
var m_VertexCount = reader.ReadUInt32();
|
||||
// vector m_Channels
|
||||
size = reader.ReadInt32();
|
||||
reader.Position += size * 4; //ChannelInfo data
|
||||
// TypelessData m_DataSize
|
||||
size = reader.ReadInt32();
|
||||
reader.Position += size; //UInt8 data
|
||||
reader.AlignStream(4);
|
||||
}
|
||||
else
|
||||
{
|
||||
// vector vertices
|
||||
var size = reader.ReadInt32();
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
//SpriteVertex data
|
||||
reader.Position += 12; //Vector3f pos
|
||||
if (version[0] < 4 || (version[0] == 4 && version[1] <= 3)) //4.3 and down
|
||||
reader.Position += 8; //Vector2f uv
|
||||
}
|
||||
|
||||
// vector indices
|
||||
size = reader.ReadInt32();
|
||||
reader.Position += 2 * size; //UInt16 data
|
||||
reader.AlignStream(4);
|
||||
}
|
||||
|
||||
// Rectf textureRect
|
||||
textureRect = new RectangleF(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
|
||||
// Vector2f textureRectOffset
|
||||
reader.Position += 8;
|
||||
// Vector2f atlasRectOffset - 5.6 and up
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 6)) //5.6 and up
|
||||
{
|
||||
reader.Position += 8;
|
||||
}
|
||||
// unsigned int settingsRaw
|
||||
reader.Position += 4;
|
||||
// Vector4f uvTransform - 4.5 and up
|
||||
if (version[0] > 4 || (version[0] == 4 && version[1] >= 5)) //4.5 and up
|
||||
{
|
||||
reader.Position += 16;
|
||||
}
|
||||
if (version[0] >= 2017) //2017 and up
|
||||
{
|
||||
// float downscaleMultiplier - 2017 and up
|
||||
reader.Position += 4;
|
||||
//vector m_PhysicsShape - 2017 and up
|
||||
var m_PhysicsShape_size = reader.ReadInt32();
|
||||
m_PhysicsShape = new PointF[m_PhysicsShape_size][];
|
||||
for (int i = 0; i < m_PhysicsShape_size; i++)
|
||||
{
|
||||
var data_size = reader.ReadInt32();
|
||||
//Vector2f
|
||||
m_PhysicsShape[i] = new PointF[data_size];
|
||||
for (int j = 0; j < data_size; j++)
|
||||
{
|
||||
m_PhysicsShape[i][j] = new PointF(reader.ReadSingle(), reader.ReadSingle());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
preloadData.Text = m_Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,59 +4,59 @@ using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Unity_Studio
|
||||
namespace AssetStudio
|
||||
{
|
||||
class SpriteAtlas
|
||||
{
|
||||
public List<PPtr> m_PackedSprites = new List<PPtr>();
|
||||
public List<PPtr> textures = new List<PPtr>();
|
||||
public List<RectangleF> textureRects = new List<RectangleF>();
|
||||
public List<Guid> guids = new List<Guid>();
|
||||
|
||||
|
||||
public SpriteAtlas(AssetPreloadData preloadData)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var a_Stream = preloadData.sourceFile.a_Stream;
|
||||
a_Stream.Position = preloadData.Offset;
|
||||
var reader = preloadData.InitReader();
|
||||
|
||||
var m_Name = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
var m_Name = reader.ReadAlignedString();
|
||||
//vector m_PackedSprites
|
||||
var size = a_Stream.ReadInt32();
|
||||
var size = reader.ReadInt32();
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
//PPtr<Sprite> data
|
||||
m_PackedSprites.Add(sourceFile.ReadPPtr());
|
||||
sourceFile.ReadPPtr();
|
||||
}
|
||||
//vector m_PackedSpriteNamesToIndex
|
||||
size = a_Stream.ReadInt32();
|
||||
size = reader.ReadInt32();
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
var data = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
var data = reader.ReadAlignedString();
|
||||
}
|
||||
//map m_RenderDataMap
|
||||
size = a_Stream.ReadInt32();
|
||||
size = reader.ReadInt32();
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
//pair first
|
||||
a_Stream.Position += 24;
|
||||
guids.Add(new Guid(reader.ReadBytes(16)));
|
||||
var second = reader.ReadInt64();
|
||||
//SpriteAtlasData second
|
||||
// PPtr<Texture2D> texture
|
||||
textures.Add(sourceFile.ReadPPtr());
|
||||
// PPtr<Texture2D> alphaTexture
|
||||
var alphaTexture = sourceFile.ReadPPtr();
|
||||
// Rectf textureRect
|
||||
textureRects.Add(new RectangleF(a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle()));
|
||||
textureRects.Add(new RectangleF(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()));
|
||||
// Vector2f textureRectOffset
|
||||
a_Stream.Position += 8;
|
||||
reader.Position += 8;
|
||||
if (sourceFile.version[0] > 2017 || (sourceFile.version[0] == 2017 && sourceFile.version[1] >= 2))//2017.2 and up
|
||||
{
|
||||
// Vector2f atlasRectOffset
|
||||
a_Stream.Position += 8;
|
||||
reader.Position += 8;
|
||||
}
|
||||
// Vector4f uvTransform
|
||||
// float downscaleMultiplier
|
||||
// unsigned int settingsRaw
|
||||
a_Stream.Position += 24;
|
||||
reader.Position += 24;
|
||||
}
|
||||
//string m_Tag
|
||||
//bool m_IsVariant
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
|
||||
namespace Unity_Studio
|
||||
namespace AssetStudio
|
||||
{
|
||||
class TextAsset
|
||||
{
|
||||
@@ -14,21 +14,20 @@ namespace Unity_Studio
|
||||
public TextAsset(AssetPreloadData preloadData, bool readSwitch)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var a_Stream = preloadData.sourceFile.a_Stream;
|
||||
a_Stream.Position = preloadData.Offset;
|
||||
var reader = preloadData.InitReader();
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
{
|
||||
uint m_ObjectHideFlags = a_Stream.ReadUInt32();
|
||||
uint m_ObjectHideFlags = reader.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
m_Name = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
m_Name = reader.ReadAlignedString();
|
||||
|
||||
if (readSwitch)
|
||||
{
|
||||
m_Script = a_Stream.ReadBytes(a_Stream.ReadInt32());
|
||||
m_Script = reader.ReadBytes(reader.ReadInt32());
|
||||
}
|
||||
else
|
||||
{
|
||||
540
AssetStudio/Classes/Texture2D.Converter.cs
Normal file
540
AssetStudio/Classes/Texture2D.Converter.cs
Normal file
@@ -0,0 +1,540 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
partial class Texture2D
|
||||
{
|
||||
[DllImport("PVRTexLibWrapper.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern bool DecompressPVR(byte[] buffer, IntPtr bmp, int len);
|
||||
|
||||
[DllImport("TextureConverterWrapper.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern bool Ponvert(byte[] buffer, IntPtr bmp, int nWidth, int nHeight, int len, int type, int bmpsize, bool fixAlpha);
|
||||
|
||||
[DllImport("crunch.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern bool DecompressCRN(byte[] pSrc_file_data, int src_file_size, out IntPtr uncompressedData, out int uncompressedSize);
|
||||
|
||||
[DllImport("crunchunity.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern bool DecompressUnityCRN(byte[] pSrc_file_data, int src_file_size, out IntPtr uncompressedData, out int uncompressedSize);
|
||||
|
||||
[DllImport("texgenpack.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern void texgenpackdecode(int texturetype, byte[] texturedata, int width, int height, IntPtr bmp, bool fixAlpha);
|
||||
|
||||
|
||||
public byte[] ConvertToContainer()
|
||||
{
|
||||
if (image_data == null || image_data.Length == 0)
|
||||
return null;
|
||||
switch (m_TextureFormat)
|
||||
{
|
||||
case TextureFormat.Alpha8:
|
||||
case TextureFormat.ARGB4444:
|
||||
case TextureFormat.RGB24:
|
||||
case TextureFormat.RGBA32:
|
||||
case TextureFormat.ARGB32:
|
||||
case TextureFormat.RGB565:
|
||||
case TextureFormat.R16:
|
||||
case TextureFormat.DXT1:
|
||||
case TextureFormat.DXT5:
|
||||
case TextureFormat.RGBA4444:
|
||||
case TextureFormat.BGRA32:
|
||||
case TextureFormat.RG16:
|
||||
case TextureFormat.R8:
|
||||
return ConvertToDDS();
|
||||
case TextureFormat.YUY2:
|
||||
case TextureFormat.PVRTC_RGB2:
|
||||
case TextureFormat.PVRTC_RGBA2:
|
||||
case TextureFormat.PVRTC_RGB4:
|
||||
case TextureFormat.PVRTC_RGBA4:
|
||||
case TextureFormat.ETC_RGB4:
|
||||
case TextureFormat.ETC2_RGB:
|
||||
case TextureFormat.ETC2_RGBA1:
|
||||
case TextureFormat.ETC2_RGBA8:
|
||||
case TextureFormat.ASTC_RGB_4x4:
|
||||
case TextureFormat.ASTC_RGB_5x5:
|
||||
case TextureFormat.ASTC_RGB_6x6:
|
||||
case TextureFormat.ASTC_RGB_8x8:
|
||||
case TextureFormat.ASTC_RGB_10x10:
|
||||
case TextureFormat.ASTC_RGB_12x12:
|
||||
case TextureFormat.ASTC_RGBA_4x4:
|
||||
case TextureFormat.ASTC_RGBA_5x5:
|
||||
case TextureFormat.ASTC_RGBA_6x6:
|
||||
case TextureFormat.ASTC_RGBA_8x8:
|
||||
case TextureFormat.ASTC_RGBA_10x10:
|
||||
case TextureFormat.ASTC_RGBA_12x12:
|
||||
case TextureFormat.ETC_RGB4_3DS:
|
||||
case TextureFormat.ETC_RGBA8_3DS:
|
||||
return ConvertToPVR();
|
||||
case TextureFormat.RHalf:
|
||||
case TextureFormat.RGHalf:
|
||||
case TextureFormat.RGBAHalf:
|
||||
case TextureFormat.RFloat:
|
||||
case TextureFormat.RGFloat:
|
||||
case TextureFormat.RGBAFloat:
|
||||
case TextureFormat.BC4:
|
||||
case TextureFormat.BC5:
|
||||
case TextureFormat.BC6H:
|
||||
case TextureFormat.BC7:
|
||||
case TextureFormat.ATC_RGB4:
|
||||
case TextureFormat.ATC_RGBA8:
|
||||
case TextureFormat.EAC_R:
|
||||
case TextureFormat.EAC_R_SIGNED:
|
||||
case TextureFormat.EAC_RG:
|
||||
case TextureFormat.EAC_RG_SIGNED:
|
||||
return ConvertToKTX();
|
||||
default:
|
||||
return image_data;
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] ConvertToDDS()
|
||||
{
|
||||
var imageBuffer = new byte[128 + image_data_size];
|
||||
dwMagic.CopyTo(imageBuffer, 0);
|
||||
BitConverter.GetBytes(dwFlags).CopyTo(imageBuffer, 8);
|
||||
BitConverter.GetBytes(m_Height).CopyTo(imageBuffer, 12);
|
||||
BitConverter.GetBytes(m_Width).CopyTo(imageBuffer, 16);
|
||||
BitConverter.GetBytes(dwPitchOrLinearSize).CopyTo(imageBuffer, 20);
|
||||
BitConverter.GetBytes(dwMipMapCount).CopyTo(imageBuffer, 28);
|
||||
BitConverter.GetBytes(dwSize).CopyTo(imageBuffer, 76);
|
||||
BitConverter.GetBytes(dwFlags2).CopyTo(imageBuffer, 80);
|
||||
BitConverter.GetBytes(dwFourCC).CopyTo(imageBuffer, 84);
|
||||
BitConverter.GetBytes(dwRGBBitCount).CopyTo(imageBuffer, 88);
|
||||
BitConverter.GetBytes(dwRBitMask).CopyTo(imageBuffer, 92);
|
||||
BitConverter.GetBytes(dwGBitMask).CopyTo(imageBuffer, 96);
|
||||
BitConverter.GetBytes(dwBBitMask).CopyTo(imageBuffer, 100);
|
||||
BitConverter.GetBytes(dwABitMask).CopyTo(imageBuffer, 104);
|
||||
BitConverter.GetBytes(dwCaps).CopyTo(imageBuffer, 108);
|
||||
BitConverter.GetBytes(dwCaps2).CopyTo(imageBuffer, 112);
|
||||
image_data.CopyTo(imageBuffer, 128);
|
||||
return imageBuffer;
|
||||
}
|
||||
|
||||
private byte[] ConvertToPVR()
|
||||
{
|
||||
var mstream = new MemoryStream();
|
||||
using (var writer = new BinaryWriter(mstream))
|
||||
{
|
||||
writer.Write(pvrVersion);
|
||||
writer.Write(pvrFlags);
|
||||
writer.Write(pvrPixelFormat);
|
||||
writer.Write(pvrColourSpace);
|
||||
writer.Write(pvrChannelType);
|
||||
writer.Write(m_Height);
|
||||
writer.Write(m_Width);
|
||||
writer.Write(pvrDepth);
|
||||
writer.Write(pvrNumSurfaces);
|
||||
writer.Write(pvrNumFaces);
|
||||
writer.Write(dwMipMapCount);
|
||||
writer.Write(pvrMetaDataSize);
|
||||
writer.Write(image_data);
|
||||
return mstream.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] ConvertToKTX()
|
||||
{
|
||||
var mstream = new MemoryStream();
|
||||
using (var writer = new BinaryWriter(mstream))
|
||||
{
|
||||
writer.Write(KTXHeader.IDENTIFIER);
|
||||
writer.Write(KTXHeader.ENDIANESS_LE);
|
||||
writer.Write(glType);
|
||||
writer.Write(glTypeSize);
|
||||
writer.Write(glFormat);
|
||||
writer.Write(glInternalFormat);
|
||||
writer.Write(glBaseInternalFormat);
|
||||
writer.Write(m_Width);
|
||||
writer.Write(m_Height);
|
||||
writer.Write(pixelDepth);
|
||||
writer.Write(numberOfArrayElements);
|
||||
writer.Write(numberOfFaces);
|
||||
writer.Write(numberOfMipmapLevels);
|
||||
writer.Write(bytesOfKeyValueData);
|
||||
writer.Write(image_data_size);
|
||||
writer.Write(image_data);
|
||||
return mstream.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public Bitmap ConvertToBitmap(bool flip)
|
||||
{
|
||||
if (image_data == null || image_data.Length == 0)
|
||||
return null;
|
||||
Bitmap bitmap;
|
||||
switch (m_TextureFormat)
|
||||
{
|
||||
case TextureFormat.Alpha8:
|
||||
case TextureFormat.ARGB4444:
|
||||
case TextureFormat.RGB24:
|
||||
case TextureFormat.RGBA32:
|
||||
case TextureFormat.ARGB32:
|
||||
case TextureFormat.R16:
|
||||
case TextureFormat.RGBA4444:
|
||||
case TextureFormat.BGRA32:
|
||||
case TextureFormat.RG16:
|
||||
case TextureFormat.R8:
|
||||
bitmap = BGRA32ToBitmap();
|
||||
break;
|
||||
case TextureFormat.RGB565:
|
||||
bitmap = RGB565ToBitmap();
|
||||
break;
|
||||
case TextureFormat.YUY2:
|
||||
case TextureFormat.PVRTC_RGB2:
|
||||
case TextureFormat.PVRTC_RGBA2:
|
||||
case TextureFormat.PVRTC_RGB4:
|
||||
case TextureFormat.PVRTC_RGBA4:
|
||||
case TextureFormat.ETC_RGB4:
|
||||
case TextureFormat.ETC2_RGB:
|
||||
case TextureFormat.ETC2_RGBA1:
|
||||
case TextureFormat.ETC2_RGBA8:
|
||||
case TextureFormat.ASTC_RGB_4x4:
|
||||
case TextureFormat.ASTC_RGB_5x5:
|
||||
case TextureFormat.ASTC_RGB_6x6:
|
||||
case TextureFormat.ASTC_RGB_8x8:
|
||||
case TextureFormat.ASTC_RGB_10x10:
|
||||
case TextureFormat.ASTC_RGB_12x12:
|
||||
case TextureFormat.ASTC_RGBA_4x4:
|
||||
case TextureFormat.ASTC_RGBA_5x5:
|
||||
case TextureFormat.ASTC_RGBA_6x6:
|
||||
case TextureFormat.ASTC_RGBA_8x8:
|
||||
case TextureFormat.ASTC_RGBA_10x10:
|
||||
case TextureFormat.ASTC_RGBA_12x12:
|
||||
case TextureFormat.ETC_RGB4_3DS:
|
||||
case TextureFormat.ETC_RGBA8_3DS:
|
||||
bitmap = PVRToBitmap(ConvertToPVR());
|
||||
break;
|
||||
case TextureFormat.DXT1:
|
||||
case TextureFormat.DXT5:
|
||||
case TextureFormat.RHalf:
|
||||
case TextureFormat.RGHalf:
|
||||
case TextureFormat.RGBAHalf:
|
||||
case TextureFormat.RFloat:
|
||||
case TextureFormat.RGFloat:
|
||||
case TextureFormat.RGBAFloat:
|
||||
case TextureFormat.RGB9e5Float:
|
||||
case TextureFormat.ATC_RGB4:
|
||||
case TextureFormat.ATC_RGBA8:
|
||||
case TextureFormat.EAC_R:
|
||||
case TextureFormat.EAC_R_SIGNED:
|
||||
case TextureFormat.EAC_RG:
|
||||
case TextureFormat.EAC_RG_SIGNED:
|
||||
bitmap = TextureConverter();
|
||||
break;
|
||||
case TextureFormat.BC4:
|
||||
case TextureFormat.BC5:
|
||||
case TextureFormat.BC6H:
|
||||
case TextureFormat.BC7:
|
||||
bitmap = Texgenpack();
|
||||
break;
|
||||
case TextureFormat.DXT1Crunched:
|
||||
case TextureFormat.DXT5Crunched:
|
||||
DecompressCRN();
|
||||
bitmap = TextureConverter();
|
||||
break;
|
||||
case TextureFormat.ETC_RGB4Crunched:
|
||||
case TextureFormat.ETC2_RGBA8Crunched:
|
||||
DecompressCRN();
|
||||
bitmap = PVRToBitmap(ConvertToPVR());
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
if (bitmap != null && flip)
|
||||
bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
private Bitmap BGRA32ToBitmap()
|
||||
{
|
||||
var hObject = GCHandle.Alloc(image_data, GCHandleType.Pinned);
|
||||
var pObject = hObject.AddrOfPinnedObject();
|
||||
var bitmap = new Bitmap(m_Width, m_Height, m_Width * 4, PixelFormat.Format32bppArgb, pObject);
|
||||
hObject.Free();
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
private Bitmap RGB565ToBitmap()
|
||||
{
|
||||
//stride = m_Width * 2 + m_Width * 2 % 4
|
||||
//所以m_Width * 2不为4的倍数时,需要在每行补上相应的像素
|
||||
byte[] buff;
|
||||
var padding = m_Width * 2 % 4;
|
||||
var stride = m_Width * 2 + padding;
|
||||
if (padding != 0)
|
||||
{
|
||||
buff = new byte[stride * m_Height];
|
||||
for (int i = 0; i < m_Height; i++)
|
||||
{
|
||||
Array.Copy(image_data, i * m_Width * 2, buff, i * stride, m_Width * 2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
buff = image_data;
|
||||
}
|
||||
var hObject = GCHandle.Alloc(buff, GCHandleType.Pinned);
|
||||
var pObject = hObject.AddrOfPinnedObject();
|
||||
var bitmap = new Bitmap(m_Width, m_Height, stride, PixelFormat.Format16bppRgb565, pObject);
|
||||
hObject.Free();
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
private Bitmap PVRToBitmap(byte[] pvrdata)
|
||||
{
|
||||
var bitmap = new Bitmap(m_Width, m_Height);
|
||||
var rect = new Rectangle(0, 0, m_Width, m_Height);
|
||||
var bmd = bitmap.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||
var len = Math.Abs(bmd.Stride) * bmd.Height;
|
||||
if (!DecompressPVR(pvrdata, bmd.Scan0, len))
|
||||
{
|
||||
bitmap.UnlockBits(bmd);
|
||||
bitmap.Dispose();
|
||||
return null;
|
||||
}
|
||||
bitmap.UnlockBits(bmd);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
private Bitmap TextureConverter()
|
||||
{
|
||||
var bitmap = new Bitmap(m_Width, m_Height);
|
||||
var rect = new Rectangle(0, 0, m_Width, m_Height);
|
||||
var bmd = bitmap.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||
var len = Math.Abs(bmd.Stride) * bmd.Height;
|
||||
var fixAlpha = glBaseInternalFormat == KTXHeader.GL_RED || glBaseInternalFormat == KTXHeader.GL_RG;
|
||||
if (!Ponvert(image_data, bmd.Scan0, m_Width, m_Height, image_data_size, (int)q_format, len, fixAlpha))
|
||||
{
|
||||
bitmap.UnlockBits(bmd);
|
||||
bitmap.Dispose();
|
||||
return null;
|
||||
}
|
||||
bitmap.UnlockBits(bmd);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
private void DecompressCRN()
|
||||
{
|
||||
IntPtr uncompressedData;
|
||||
int uncompressedSize;
|
||||
bool result;
|
||||
if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 3)) //2017.3 and up
|
||||
{
|
||||
result = DecompressUnityCRN(image_data, image_data_size, out uncompressedData, out uncompressedSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = DecompressCRN(image_data, image_data_size, out uncompressedData, out uncompressedSize);
|
||||
}
|
||||
|
||||
if (result)
|
||||
{
|
||||
var uncompressedBytes = new byte[uncompressedSize];
|
||||
Marshal.Copy(uncompressedData, uncompressedBytes, 0, uncompressedSize);
|
||||
Marshal.FreeHGlobal(uncompressedData);
|
||||
image_data = uncompressedBytes;
|
||||
image_data_size = uncompressedSize;
|
||||
}
|
||||
}
|
||||
|
||||
private Bitmap Texgenpack()
|
||||
{
|
||||
var bitmap = new Bitmap(m_Width, m_Height);
|
||||
var rect = new Rectangle(0, 0, m_Width, m_Height);
|
||||
var bmd = bitmap.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||
var fixAlpha = glBaseInternalFormat == KTXHeader.GL_RED || glBaseInternalFormat == KTXHeader.GL_RG;
|
||||
texgenpackdecode((int)texturetype, image_data, m_Width, m_Height, bmd.Scan0, fixAlpha);
|
||||
bitmap.UnlockBits(bmd);
|
||||
return bitmap;
|
||||
}
|
||||
}
|
||||
|
||||
public static class KTXHeader
|
||||
{
|
||||
public static byte[] IDENTIFIER = { 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A };
|
||||
public static byte[] ENDIANESS_LE = { 1, 2, 3, 4 };
|
||||
public static byte[] ENDIANESS_BE = { 4, 3, 2, 1 };
|
||||
|
||||
// constants for glInternalFormat
|
||||
public static int GL_ETC1_RGB8_OES = 0x8D64;
|
||||
|
||||
public static int GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00;
|
||||
public static int GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01;
|
||||
public static int GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02;
|
||||
public static int GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03;
|
||||
|
||||
public static int GL_ATC_RGB_AMD = 0x8C92;
|
||||
public static int GL_ATC_RGBA_EXPLICIT_ALPHA_AMD = 0x8C93;
|
||||
public static int GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD = 0x87EE;
|
||||
|
||||
public static int GL_COMPRESSED_RGB8_ETC2 = 0x9274;
|
||||
public static int GL_COMPRESSED_SRGB8_ETC2 = 0x9275;
|
||||
public static int GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9276;
|
||||
public static int GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9277;
|
||||
public static int GL_COMPRESSED_RGBA8_ETC2_EAC = 0x9278;
|
||||
public static int GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 0x9279;
|
||||
public static int GL_COMPRESSED_R11_EAC = 0x9270;
|
||||
public static int GL_COMPRESSED_SIGNED_R11_EAC = 0x9271;
|
||||
public static int GL_COMPRESSED_RG11_EAC = 0x9272;
|
||||
public static int GL_COMPRESSED_SIGNED_RG11_EAC = 0x9273;
|
||||
|
||||
public static int GL_COMPRESSED_RED_RGTC1 = 0x8DBB;
|
||||
public static int GL_COMPRESSED_RG_RGTC2 = 0x8DBD;
|
||||
public static int GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT = 0x8E8F;
|
||||
public static int GL_COMPRESSED_RGBA_BPTC_UNORM = 0x8E8C;
|
||||
|
||||
public static int GL_R16F = 0x822D;
|
||||
public static int GL_RG16F = 0x822F;
|
||||
public static int GL_RGBA16F = 0x881A;
|
||||
public static int GL_R32F = 0x822E;
|
||||
public static int GL_RG32F = 0x8230;
|
||||
public static int GL_RGBA32F = 0x8814;
|
||||
|
||||
// constants for glBaseInternalFormat
|
||||
public static int GL_RED = 0x1903;
|
||||
public static int GL_GREEN = 0x1904;
|
||||
public static int GL_BLUE = 0x1905;
|
||||
public static int GL_ALPHA = 0x1906;
|
||||
public static int GL_RGB = 0x1907;
|
||||
public static int GL_RGBA = 0x1908;
|
||||
public static int GL_RG = 0x8227;
|
||||
}
|
||||
|
||||
//from TextureConverter.h
|
||||
public enum QFORMAT
|
||||
{
|
||||
// General formats
|
||||
Q_FORMAT_RGBA_8UI = 1,
|
||||
Q_FORMAT_RGBA_8I,
|
||||
Q_FORMAT_RGB5_A1UI,
|
||||
Q_FORMAT_RGBA_4444,
|
||||
Q_FORMAT_RGBA_16UI,
|
||||
Q_FORMAT_RGBA_16I,
|
||||
Q_FORMAT_RGBA_32UI,
|
||||
Q_FORMAT_RGBA_32I,
|
||||
|
||||
Q_FORMAT_PALETTE_8_RGBA_8888,
|
||||
Q_FORMAT_PALETTE_8_RGBA_5551,
|
||||
Q_FORMAT_PALETTE_8_RGBA_4444,
|
||||
Q_FORMAT_PALETTE_4_RGBA_8888,
|
||||
Q_FORMAT_PALETTE_4_RGBA_5551,
|
||||
Q_FORMAT_PALETTE_4_RGBA_4444,
|
||||
Q_FORMAT_PALETTE_1_RGBA_8888,
|
||||
Q_FORMAT_PALETTE_8_RGB_888,
|
||||
Q_FORMAT_PALETTE_8_RGB_565,
|
||||
Q_FORMAT_PALETTE_4_RGB_888,
|
||||
Q_FORMAT_PALETTE_4_RGB_565,
|
||||
|
||||
Q_FORMAT_R2_GBA10UI,
|
||||
Q_FORMAT_RGB10_A2UI,
|
||||
Q_FORMAT_RGB10_A2I,
|
||||
Q_FORMAT_RGBA_F,
|
||||
Q_FORMAT_RGBA_HF,
|
||||
|
||||
Q_FORMAT_RGB9_E5, // Last five bits are exponent bits (Read following section in GLES3 spec: "3.8.17 Shared Exponent Texture Color Conversion")
|
||||
Q_FORMAT_RGB_8UI,
|
||||
Q_FORMAT_RGB_8I,
|
||||
Q_FORMAT_RGB_565,
|
||||
Q_FORMAT_RGB_16UI,
|
||||
Q_FORMAT_RGB_16I,
|
||||
Q_FORMAT_RGB_32UI,
|
||||
Q_FORMAT_RGB_32I,
|
||||
|
||||
Q_FORMAT_RGB_F,
|
||||
Q_FORMAT_RGB_HF,
|
||||
Q_FORMAT_RGB_11_11_10_F,
|
||||
|
||||
Q_FORMAT_RG_F,
|
||||
Q_FORMAT_RG_HF,
|
||||
Q_FORMAT_RG_32UI,
|
||||
Q_FORMAT_RG_32I,
|
||||
Q_FORMAT_RG_16I,
|
||||
Q_FORMAT_RG_16UI,
|
||||
Q_FORMAT_RG_8I,
|
||||
Q_FORMAT_RG_8UI,
|
||||
Q_FORMAT_RG_S88,
|
||||
|
||||
Q_FORMAT_R_32UI,
|
||||
Q_FORMAT_R_32I,
|
||||
Q_FORMAT_R_F,
|
||||
Q_FORMAT_R_16F,
|
||||
Q_FORMAT_R_16I,
|
||||
Q_FORMAT_R_16UI,
|
||||
Q_FORMAT_R_8I,
|
||||
Q_FORMAT_R_8UI,
|
||||
|
||||
Q_FORMAT_LUMINANCE_ALPHA_88,
|
||||
Q_FORMAT_LUMINANCE_8,
|
||||
Q_FORMAT_ALPHA_8,
|
||||
|
||||
Q_FORMAT_LUMINANCE_ALPHA_F,
|
||||
Q_FORMAT_LUMINANCE_F,
|
||||
Q_FORMAT_ALPHA_F,
|
||||
Q_FORMAT_LUMINANCE_ALPHA_HF,
|
||||
Q_FORMAT_LUMINANCE_HF,
|
||||
Q_FORMAT_ALPHA_HF,
|
||||
Q_FORMAT_DEPTH_16,
|
||||
Q_FORMAT_DEPTH_24,
|
||||
Q_FORMAT_DEPTH_24_STENCIL_8,
|
||||
Q_FORMAT_DEPTH_32,
|
||||
|
||||
Q_FORMAT_BGR_565,
|
||||
Q_FORMAT_BGRA_8888,
|
||||
Q_FORMAT_BGRA_5551,
|
||||
Q_FORMAT_BGRX_8888,
|
||||
Q_FORMAT_BGRA_4444,
|
||||
// Compressed formats
|
||||
Q_FORMAT_ATITC_RGBA,
|
||||
Q_FORMAT_ATC_RGBA_EXPLICIT_ALPHA = Q_FORMAT_ATITC_RGBA,
|
||||
Q_FORMAT_ATITC_RGB,
|
||||
Q_FORMAT_ATC_RGB = Q_FORMAT_ATITC_RGB,
|
||||
Q_FORMAT_ATC_RGBA_INTERPOLATED_ALPHA,
|
||||
Q_FORMAT_ETC1_RGB8,
|
||||
Q_FORMAT_3DC_X,
|
||||
Q_FORMAT_3DC_XY,
|
||||
|
||||
Q_FORMAT_ETC2_RGB8,
|
||||
Q_FORMAT_ETC2_RGBA8,
|
||||
Q_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1,
|
||||
Q_FORMAT_ETC2_SRGB8,
|
||||
Q_FORMAT_ETC2_SRGB8_ALPHA8,
|
||||
Q_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1,
|
||||
Q_FORMAT_EAC_R_SIGNED,
|
||||
Q_FORMAT_EAC_R_UNSIGNED,
|
||||
Q_FORMAT_EAC_RG_SIGNED,
|
||||
Q_FORMAT_EAC_RG_UNSIGNED,
|
||||
|
||||
Q_FORMAT_S3TC_DXT1_RGB,
|
||||
Q_FORMAT_S3TC_DXT1_RGBA,
|
||||
Q_FORMAT_S3TC_DXT3_RGBA,
|
||||
Q_FORMAT_S3TC_DXT5_RGBA,
|
||||
|
||||
// YUV formats
|
||||
Q_FORMAT_AYUV_32,
|
||||
Q_FORMAT_I444_24,
|
||||
Q_FORMAT_YUYV_16,
|
||||
Q_FORMAT_UYVY_16,
|
||||
Q_FORMAT_I420_12,
|
||||
Q_FORMAT_YV12_12,
|
||||
Q_FORMAT_NV21_12,
|
||||
Q_FORMAT_NV12_12,
|
||||
|
||||
// ASTC Format
|
||||
Q_FORMAT_ASTC_8,
|
||||
Q_FORMAT_ASTC_16,
|
||||
};
|
||||
|
||||
public enum texgenpack_texturetype
|
||||
{
|
||||
RGTC1,
|
||||
RGTC2,
|
||||
BPTC_FLOAT,
|
||||
BPTC
|
||||
}
|
||||
}
|
||||
@@ -6,9 +6,9 @@ using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Unity_Studio
|
||||
namespace AssetStudio
|
||||
{
|
||||
class Texture2D
|
||||
partial class Texture2D
|
||||
{
|
||||
public string m_Name;
|
||||
public int m_Width;
|
||||
@@ -86,75 +86,65 @@ namespace Unity_Studio
|
||||
//texgenpack
|
||||
private texgenpack_texturetype texturetype;
|
||||
|
||||
[DllImport("PVRTexLibWrapper.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern bool DecompressPVR(byte[] buffer, IntPtr bmp, int len);
|
||||
|
||||
[DllImport("TextureConverterWrapper.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern bool Ponvert(byte[] buffer, IntPtr bmp, int nWidth, int nHeight, int len, int type, int bmpsize, bool fixAlpha);
|
||||
|
||||
[DllImport("crunch.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern bool DecompressCRN(byte[] pSrc_file_data, int src_file_size, out IntPtr dxtdata, out int dxtsize);
|
||||
|
||||
[DllImport("texgenpack.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern void texgenpackdecode(int texturetype, byte[] texturedata, int width, int height, IntPtr bmp, bool fixAlpha);
|
||||
private int[] version;
|
||||
|
||||
public Texture2D(AssetPreloadData preloadData, bool readSwitch)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var a_Stream = preloadData.sourceFile.a_Stream;
|
||||
a_Stream.Position = preloadData.Offset;
|
||||
var reader = preloadData.InitReader();
|
||||
version = sourceFile.version;
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
{
|
||||
uint m_ObjectHideFlags = a_Stream.ReadUInt32();
|
||||
uint m_ObjectHideFlags = reader.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
m_Name = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
if (sourceFile.version[0] > 2017 || (sourceFile.version[0] == 2017 && sourceFile.version[1] >= 3))//2017.3 and up
|
||||
m_Name = reader.ReadAlignedString();
|
||||
if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 3))//2017.3 and up
|
||||
{
|
||||
var m_ForcedFallbackFormat = a_Stream.ReadInt32();
|
||||
var m_DownscaleFallback = a_Stream.ReadBoolean();
|
||||
a_Stream.AlignStream(4);
|
||||
var m_ForcedFallbackFormat = reader.ReadInt32();
|
||||
var m_DownscaleFallback = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
}
|
||||
m_Width = a_Stream.ReadInt32();
|
||||
m_Height = a_Stream.ReadInt32();
|
||||
m_CompleteImageSize = a_Stream.ReadInt32();
|
||||
m_TextureFormat = (TextureFormat)a_Stream.ReadInt32();
|
||||
m_Width = reader.ReadInt32();
|
||||
m_Height = reader.ReadInt32();
|
||||
m_CompleteImageSize = reader.ReadInt32();
|
||||
m_TextureFormat = (TextureFormat)reader.ReadInt32();
|
||||
|
||||
if (sourceFile.version[0] < 5 || (sourceFile.version[0] == 5 && sourceFile.version[1] < 2))
|
||||
{ m_MipMap = a_Stream.ReadBoolean(); }
|
||||
if (version[0] < 5 || (version[0] == 5 && version[1] < 2))
|
||||
{ m_MipMap = reader.ReadBoolean(); }
|
||||
else
|
||||
{
|
||||
dwFlags += 0x20000;
|
||||
dwMipMapCount = a_Stream.ReadInt32();//is this with or without main image?
|
||||
dwMipMapCount = reader.ReadInt32();//is this with or without main image?
|
||||
dwCaps += 0x400008;
|
||||
}
|
||||
|
||||
m_IsReadable = a_Stream.ReadBoolean(); //2.6.0 and up
|
||||
m_ReadAllowed = a_Stream.ReadBoolean(); //3.0.0 - 5.4
|
||||
a_Stream.AlignStream(4);
|
||||
m_IsReadable = reader.ReadBoolean(); //2.6.0 and up
|
||||
m_ReadAllowed = reader.ReadBoolean(); //3.0.0 - 5.4
|
||||
reader.AlignStream(4);
|
||||
|
||||
m_ImageCount = a_Stream.ReadInt32();
|
||||
m_TextureDimension = a_Stream.ReadInt32();
|
||||
m_ImageCount = reader.ReadInt32();
|
||||
m_TextureDimension = reader.ReadInt32();
|
||||
//m_TextureSettings
|
||||
m_FilterMode = a_Stream.ReadInt32();
|
||||
m_Aniso = a_Stream.ReadInt32();
|
||||
m_MipBias = a_Stream.ReadSingle();
|
||||
m_WrapMode = a_Stream.ReadInt32();
|
||||
if (sourceFile.version[0] >= 2017)//2017.x and up
|
||||
m_FilterMode = reader.ReadInt32();
|
||||
m_Aniso = reader.ReadInt32();
|
||||
m_MipBias = reader.ReadSingle();
|
||||
m_WrapMode = reader.ReadInt32();
|
||||
if (version[0] >= 2017)//2017.x and up
|
||||
{
|
||||
int m_WrapV = a_Stream.ReadInt32();
|
||||
int m_WrapW = a_Stream.ReadInt32();
|
||||
int m_WrapV = reader.ReadInt32();
|
||||
int m_WrapW = reader.ReadInt32();
|
||||
}
|
||||
if (sourceFile.version[0] >= 3)
|
||||
if (version[0] >= 3)
|
||||
{
|
||||
m_LightmapFormat = a_Stream.ReadInt32();
|
||||
if (sourceFile.version[0] >= 4 || sourceFile.version[1] >= 5) { m_ColorSpace = a_Stream.ReadInt32(); } //3.5.0 and up
|
||||
m_LightmapFormat = reader.ReadInt32();
|
||||
if (version[0] >= 4 || version[1] >= 5) { m_ColorSpace = reader.ReadInt32(); } //3.5.0 and up
|
||||
}
|
||||
|
||||
image_data_size = a_Stream.ReadInt32();
|
||||
image_data_size = reader.ReadInt32();
|
||||
|
||||
if (m_MipMap)
|
||||
{
|
||||
@@ -163,43 +153,52 @@ namespace Unity_Studio
|
||||
dwCaps += 0x400008;
|
||||
}
|
||||
|
||||
if (image_data_size == 0 && ((sourceFile.version[0] == 5 && sourceFile.version[1] >= 3) || sourceFile.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
|
||||
{
|
||||
offset = a_Stream.ReadUInt32();
|
||||
size = a_Stream.ReadUInt32();
|
||||
offset = reader.ReadUInt32();
|
||||
size = reader.ReadUInt32();
|
||||
image_data_size = (int)size;
|
||||
path = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
path = reader.ReadAlignedString();
|
||||
}
|
||||
|
||||
if (readSwitch)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
path = Path.Combine(Path.GetDirectoryName(sourceFile.filePath), path.Replace("archive:/", ""));
|
||||
if (File.Exists(path) ||
|
||||
File.Exists(path = Path.Combine(Path.GetDirectoryName(sourceFile.filePath), Path.GetFileName(path))))
|
||||
var resourceFileName = Path.GetFileName(path);
|
||||
var resourceFilePath = Path.GetDirectoryName(sourceFile.filePath) + "\\" + resourceFileName;
|
||||
if (!File.Exists(resourceFilePath))
|
||||
{
|
||||
BinaryReader reader = new BinaryReader(File.OpenRead(path));
|
||||
reader.BaseStream.Position = offset;
|
||||
image_data = reader.ReadBytes(image_data_size);
|
||||
reader.Close();
|
||||
var findFiles = Directory.GetFiles(Path.GetDirectoryName(sourceFile.filePath), resourceFileName, SearchOption.AllDirectories);
|
||||
if (findFiles.Length > 0)
|
||||
{
|
||||
resourceFilePath = findFiles[0];
|
||||
}
|
||||
}
|
||||
if (File.Exists(resourceFilePath))
|
||||
{
|
||||
using (var resourceReader = new BinaryReader(File.OpenRead(resourceFilePath)))
|
||||
{
|
||||
resourceReader.BaseStream.Position = offset;
|
||||
image_data = resourceReader.ReadBytes(image_data_size);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (UnityStudio.assetsfileandstream.TryGetValue(Path.GetFileName(path), out var estream))
|
||||
if (Studio.resourceFileReaders.TryGetValue(resourceFileName.ToUpper(), out var resourceReader))
|
||||
{
|
||||
estream.Position = offset;
|
||||
image_data = estream.ReadBytes(image_data_size);
|
||||
resourceReader.Position = offset;
|
||||
image_data = resourceReader.ReadBytes(image_data_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show($"can't find the resource file {Path.GetFileName(path)}");
|
||||
MessageBox.Show($"can't find the resource file {resourceFileName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
image_data = a_Stream.ReadBytes(image_data_size);
|
||||
image_data = reader.ReadBytes(image_data_size);
|
||||
}
|
||||
|
||||
switch (m_TextureFormat)
|
||||
@@ -775,503 +774,66 @@ namespace Unity_Studio
|
||||
dwBBitMask = 0xFF;
|
||||
dwABitMask = -16777216;
|
||||
}
|
||||
|
||||
public byte[] ConvertToContainer()
|
||||
{
|
||||
if (image_data == null || image_data.Length == 0)
|
||||
return null;
|
||||
switch (m_TextureFormat)
|
||||
{
|
||||
case TextureFormat.Alpha8:
|
||||
case TextureFormat.ARGB4444:
|
||||
case TextureFormat.RGB24:
|
||||
case TextureFormat.RGBA32:
|
||||
case TextureFormat.ARGB32:
|
||||
case TextureFormat.RGB565:
|
||||
case TextureFormat.R16:
|
||||
case TextureFormat.DXT1:
|
||||
case TextureFormat.DXT5:
|
||||
case TextureFormat.RGBA4444:
|
||||
case TextureFormat.BGRA32:
|
||||
case TextureFormat.RG16:
|
||||
case TextureFormat.R8:
|
||||
return ConvertToDDS();
|
||||
case TextureFormat.YUY2:
|
||||
case TextureFormat.PVRTC_RGB2:
|
||||
case TextureFormat.PVRTC_RGBA2:
|
||||
case TextureFormat.PVRTC_RGB4:
|
||||
case TextureFormat.PVRTC_RGBA4:
|
||||
case TextureFormat.ETC_RGB4:
|
||||
case TextureFormat.ETC2_RGB:
|
||||
case TextureFormat.ETC2_RGBA1:
|
||||
case TextureFormat.ETC2_RGBA8:
|
||||
case TextureFormat.ASTC_RGB_4x4:
|
||||
case TextureFormat.ASTC_RGB_5x5:
|
||||
case TextureFormat.ASTC_RGB_6x6:
|
||||
case TextureFormat.ASTC_RGB_8x8:
|
||||
case TextureFormat.ASTC_RGB_10x10:
|
||||
case TextureFormat.ASTC_RGB_12x12:
|
||||
case TextureFormat.ASTC_RGBA_4x4:
|
||||
case TextureFormat.ASTC_RGBA_5x5:
|
||||
case TextureFormat.ASTC_RGBA_6x6:
|
||||
case TextureFormat.ASTC_RGBA_8x8:
|
||||
case TextureFormat.ASTC_RGBA_10x10:
|
||||
case TextureFormat.ASTC_RGBA_12x12:
|
||||
case TextureFormat.ETC_RGB4_3DS:
|
||||
case TextureFormat.ETC_RGBA8_3DS:
|
||||
return ConvertToPVR();
|
||||
case TextureFormat.RHalf:
|
||||
case TextureFormat.RGHalf:
|
||||
case TextureFormat.RGBAHalf:
|
||||
case TextureFormat.RFloat:
|
||||
case TextureFormat.RGFloat:
|
||||
case TextureFormat.RGBAFloat:
|
||||
case TextureFormat.BC4:
|
||||
case TextureFormat.BC5:
|
||||
case TextureFormat.BC6H:
|
||||
case TextureFormat.BC7:
|
||||
case TextureFormat.ATC_RGB4:
|
||||
case TextureFormat.ATC_RGBA8:
|
||||
case TextureFormat.EAC_R:
|
||||
case TextureFormat.EAC_R_SIGNED:
|
||||
case TextureFormat.EAC_RG:
|
||||
case TextureFormat.EAC_RG_SIGNED:
|
||||
return ConvertToKTX();
|
||||
default:
|
||||
return image_data;
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] ConvertToDDS()
|
||||
{
|
||||
var imageBuffer = new byte[128 + image_data_size];
|
||||
dwMagic.CopyTo(imageBuffer, 0);
|
||||
BitConverter.GetBytes(dwFlags).CopyTo(imageBuffer, 8);
|
||||
BitConverter.GetBytes(m_Height).CopyTo(imageBuffer, 12);
|
||||
BitConverter.GetBytes(m_Width).CopyTo(imageBuffer, 16);
|
||||
BitConverter.GetBytes(dwPitchOrLinearSize).CopyTo(imageBuffer, 20);
|
||||
BitConverter.GetBytes(dwMipMapCount).CopyTo(imageBuffer, 28);
|
||||
BitConverter.GetBytes(dwSize).CopyTo(imageBuffer, 76);
|
||||
BitConverter.GetBytes(dwFlags2).CopyTo(imageBuffer, 80);
|
||||
BitConverter.GetBytes(dwFourCC).CopyTo(imageBuffer, 84);
|
||||
BitConverter.GetBytes(dwRGBBitCount).CopyTo(imageBuffer, 88);
|
||||
BitConverter.GetBytes(dwRBitMask).CopyTo(imageBuffer, 92);
|
||||
BitConverter.GetBytes(dwGBitMask).CopyTo(imageBuffer, 96);
|
||||
BitConverter.GetBytes(dwBBitMask).CopyTo(imageBuffer, 100);
|
||||
BitConverter.GetBytes(dwABitMask).CopyTo(imageBuffer, 104);
|
||||
BitConverter.GetBytes(dwCaps).CopyTo(imageBuffer, 108);
|
||||
BitConverter.GetBytes(dwCaps2).CopyTo(imageBuffer, 112);
|
||||
image_data.CopyTo(imageBuffer, 128);
|
||||
return imageBuffer;
|
||||
}
|
||||
|
||||
private byte[] ConvertToPVR()
|
||||
{
|
||||
var mstream = new MemoryStream();
|
||||
using (var writer = new BinaryWriter(mstream))
|
||||
{
|
||||
writer.Write(pvrVersion);
|
||||
writer.Write(pvrFlags);
|
||||
writer.Write(pvrPixelFormat);
|
||||
writer.Write(pvrColourSpace);
|
||||
writer.Write(pvrChannelType);
|
||||
writer.Write(m_Height);
|
||||
writer.Write(m_Width);
|
||||
writer.Write(pvrDepth);
|
||||
writer.Write(pvrNumSurfaces);
|
||||
writer.Write(pvrNumFaces);
|
||||
writer.Write(dwMipMapCount);
|
||||
writer.Write(pvrMetaDataSize);
|
||||
writer.Write(image_data);
|
||||
return mstream.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] ConvertToKTX()
|
||||
{
|
||||
var mstream = new MemoryStream();
|
||||
using (var writer = new BinaryWriter(mstream))
|
||||
{
|
||||
writer.Write(KTXHeader.IDENTIFIER);
|
||||
writer.Write(KTXHeader.ENDIANESS_LE);
|
||||
writer.Write(glType);
|
||||
writer.Write(glTypeSize);
|
||||
writer.Write(glFormat);
|
||||
writer.Write(glInternalFormat);
|
||||
writer.Write(glBaseInternalFormat);
|
||||
writer.Write(m_Width);
|
||||
writer.Write(m_Height);
|
||||
writer.Write(pixelDepth);
|
||||
writer.Write(numberOfArrayElements);
|
||||
writer.Write(numberOfFaces);
|
||||
writer.Write(numberOfMipmapLevels);
|
||||
writer.Write(bytesOfKeyValueData);
|
||||
writer.Write(image_data_size);
|
||||
writer.Write(image_data);
|
||||
return mstream.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public Bitmap ConvertToBitmap(bool flip)
|
||||
{
|
||||
if (image_data == null || image_data.Length == 0)
|
||||
return null;
|
||||
Bitmap bitmap;
|
||||
switch (m_TextureFormat)
|
||||
{
|
||||
case TextureFormat.Alpha8:
|
||||
case TextureFormat.ARGB4444:
|
||||
case TextureFormat.RGB24:
|
||||
case TextureFormat.RGBA32:
|
||||
case TextureFormat.ARGB32:
|
||||
case TextureFormat.R16:
|
||||
case TextureFormat.RGBA4444:
|
||||
case TextureFormat.BGRA32:
|
||||
case TextureFormat.RG16:
|
||||
case TextureFormat.R8:
|
||||
bitmap = BGRA32ToBitmap();
|
||||
break;
|
||||
case TextureFormat.RGB565:
|
||||
bitmap = RGB565ToBitmap();
|
||||
break;
|
||||
case TextureFormat.YUY2:
|
||||
case TextureFormat.PVRTC_RGB2:
|
||||
case TextureFormat.PVRTC_RGBA2:
|
||||
case TextureFormat.PVRTC_RGB4:
|
||||
case TextureFormat.PVRTC_RGBA4:
|
||||
case TextureFormat.ETC_RGB4:
|
||||
case TextureFormat.ETC2_RGB:
|
||||
case TextureFormat.ETC2_RGBA1:
|
||||
case TextureFormat.ETC2_RGBA8:
|
||||
case TextureFormat.ASTC_RGB_4x4:
|
||||
case TextureFormat.ASTC_RGB_5x5:
|
||||
case TextureFormat.ASTC_RGB_6x6:
|
||||
case TextureFormat.ASTC_RGB_8x8:
|
||||
case TextureFormat.ASTC_RGB_10x10:
|
||||
case TextureFormat.ASTC_RGB_12x12:
|
||||
case TextureFormat.ASTC_RGBA_4x4:
|
||||
case TextureFormat.ASTC_RGBA_5x5:
|
||||
case TextureFormat.ASTC_RGBA_6x6:
|
||||
case TextureFormat.ASTC_RGBA_8x8:
|
||||
case TextureFormat.ASTC_RGBA_10x10:
|
||||
case TextureFormat.ASTC_RGBA_12x12:
|
||||
case TextureFormat.ETC_RGB4_3DS:
|
||||
case TextureFormat.ETC_RGBA8_3DS:
|
||||
bitmap = PVRToBitmap(ConvertToPVR());
|
||||
break;
|
||||
case TextureFormat.DXT1:
|
||||
case TextureFormat.DXT5:
|
||||
case TextureFormat.RHalf:
|
||||
case TextureFormat.RGHalf:
|
||||
case TextureFormat.RGBAHalf:
|
||||
case TextureFormat.RFloat:
|
||||
case TextureFormat.RGFloat:
|
||||
case TextureFormat.RGBAFloat:
|
||||
case TextureFormat.RGB9e5Float:
|
||||
case TextureFormat.ATC_RGB4:
|
||||
case TextureFormat.ATC_RGBA8:
|
||||
case TextureFormat.EAC_R:
|
||||
case TextureFormat.EAC_R_SIGNED:
|
||||
case TextureFormat.EAC_RG:
|
||||
case TextureFormat.EAC_RG_SIGNED:
|
||||
bitmap = TextureConverter();
|
||||
break;
|
||||
case TextureFormat.BC4:
|
||||
case TextureFormat.BC5:
|
||||
case TextureFormat.BC6H:
|
||||
case TextureFormat.BC7:
|
||||
bitmap = Texgenpack();
|
||||
break;
|
||||
case TextureFormat.DXT1Crunched:
|
||||
case TextureFormat.DXT5Crunched:
|
||||
DecompressCRN();
|
||||
bitmap = TextureConverter();
|
||||
break;
|
||||
case TextureFormat.ETC_RGB4Crunched:
|
||||
case TextureFormat.ETC2_RGBA8Crunched:
|
||||
DecompressCRN();
|
||||
bitmap = PVRToBitmap(ConvertToPVR());
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
if (bitmap != null && flip)
|
||||
bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
private Bitmap BGRA32ToBitmap()
|
||||
{
|
||||
var hObject = GCHandle.Alloc(image_data, GCHandleType.Pinned);
|
||||
var pObject = hObject.AddrOfPinnedObject();
|
||||
var bitmap = new Bitmap(m_Width, m_Height, m_Width * 4, PixelFormat.Format32bppArgb, pObject);
|
||||
hObject.Free();
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
private Bitmap RGB565ToBitmap()
|
||||
{
|
||||
//stride = m_Width * 2 + m_Width * 2 % 4
|
||||
//所以m_Width * 2不为4的倍数时,需要在每行补上相应的像素
|
||||
byte[] buff;
|
||||
var padding = m_Width * 2 % 4;
|
||||
var stride = m_Width * 2 + padding;
|
||||
if (padding != 0)
|
||||
{
|
||||
buff = new byte[stride * m_Height];
|
||||
for (int i = 0; i < m_Height; i++)
|
||||
{
|
||||
Array.Copy(image_data, i * m_Width * 2, buff, i * stride, m_Width * 2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
buff = image_data;
|
||||
}
|
||||
var hObject = GCHandle.Alloc(buff, GCHandleType.Pinned);
|
||||
var pObject = hObject.AddrOfPinnedObject();
|
||||
var bitmap = new Bitmap(m_Width, m_Height, stride, PixelFormat.Format16bppRgb565, pObject);
|
||||
hObject.Free();
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
private Bitmap PVRToBitmap(byte[] pvrdata)
|
||||
{
|
||||
var bitmap = new Bitmap(m_Width, m_Height);
|
||||
var rect = new Rectangle(0, 0, m_Width, m_Height);
|
||||
var bmd = bitmap.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||
var len = Math.Abs(bmd.Stride) * bmd.Height;
|
||||
if (!DecompressPVR(pvrdata, bmd.Scan0, len))
|
||||
{
|
||||
bitmap.UnlockBits(bmd);
|
||||
bitmap.Dispose();
|
||||
return null;
|
||||
}
|
||||
bitmap.UnlockBits(bmd);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
private Bitmap TextureConverter()
|
||||
{
|
||||
var bitmap = new Bitmap(m_Width, m_Height);
|
||||
var rect = new Rectangle(0, 0, m_Width, m_Height);
|
||||
var bmd = bitmap.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||
var len = Math.Abs(bmd.Stride) * bmd.Height;
|
||||
var fixAlpha = glBaseInternalFormat == KTXHeader.GL_RED || glBaseInternalFormat == KTXHeader.GL_RG;
|
||||
if (!Ponvert(image_data, bmd.Scan0, m_Width, m_Height, image_data_size, (int)q_format, len, fixAlpha))
|
||||
{
|
||||
bitmap.UnlockBits(bmd);
|
||||
bitmap.Dispose();
|
||||
return null;
|
||||
}
|
||||
bitmap.UnlockBits(bmd);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
private void DecompressCRN()
|
||||
{
|
||||
if (DecompressCRN(image_data, image_data_size, out IntPtr dxtdata, out int dxtsize))
|
||||
{
|
||||
var dxtbytes = new byte[dxtsize];
|
||||
Marshal.Copy(dxtdata, dxtbytes, 0, dxtsize);
|
||||
Marshal.FreeHGlobal(dxtdata);
|
||||
image_data = dxtbytes;
|
||||
image_data_size = dxtsize;
|
||||
}
|
||||
}
|
||||
|
||||
private Bitmap Texgenpack()
|
||||
{
|
||||
var bitmap = new Bitmap(m_Width, m_Height);
|
||||
var rect = new Rectangle(0, 0, m_Width, m_Height);
|
||||
var bmd = bitmap.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||
var fixAlpha = glBaseInternalFormat == KTXHeader.GL_RED || glBaseInternalFormat == KTXHeader.GL_RG;
|
||||
texgenpackdecode((int)texturetype, image_data, m_Width, m_Height, bmd.Scan0, fixAlpha);
|
||||
bitmap.UnlockBits(bmd);
|
||||
return bitmap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class KTXHeader
|
||||
{
|
||||
public static byte[] IDENTIFIER = { 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A };
|
||||
public static byte[] ENDIANESS_LE = { 1, 2, 3, 4 };
|
||||
public static byte[] ENDIANESS_BE = { 4, 3, 2, 1 };
|
||||
|
||||
// constants for glInternalFormat
|
||||
public static int GL_ETC1_RGB8_OES = 0x8D64;
|
||||
|
||||
public static int GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00;
|
||||
public static int GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01;
|
||||
public static int GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02;
|
||||
public static int GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03;
|
||||
|
||||
public static int GL_ATC_RGB_AMD = 0x8C92;
|
||||
public static int GL_ATC_RGBA_EXPLICIT_ALPHA_AMD = 0x8C93;
|
||||
public static int GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD = 0x87EE;
|
||||
|
||||
public static int GL_COMPRESSED_RGB8_ETC2 = 0x9274;
|
||||
public static int GL_COMPRESSED_SRGB8_ETC2 = 0x9275;
|
||||
public static int GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9276;
|
||||
public static int GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9277;
|
||||
public static int GL_COMPRESSED_RGBA8_ETC2_EAC = 0x9278;
|
||||
public static int GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 0x9279;
|
||||
public static int GL_COMPRESSED_R11_EAC = 0x9270;
|
||||
public static int GL_COMPRESSED_SIGNED_R11_EAC = 0x9271;
|
||||
public static int GL_COMPRESSED_RG11_EAC = 0x9272;
|
||||
public static int GL_COMPRESSED_SIGNED_RG11_EAC = 0x9273;
|
||||
|
||||
public static int GL_COMPRESSED_RED_RGTC1 = 0x8DBB;
|
||||
public static int GL_COMPRESSED_RG_RGTC2 = 0x8DBD;
|
||||
public static int GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT = 0x8E8F;
|
||||
public static int GL_COMPRESSED_RGBA_BPTC_UNORM = 0x8E8C;
|
||||
|
||||
public static int GL_R16F = 0x822D;
|
||||
public static int GL_RG16F = 0x822F;
|
||||
public static int GL_RGBA16F = 0x881A;
|
||||
public static int GL_R32F = 0x822E;
|
||||
public static int GL_RG32F = 0x8230;
|
||||
public static int GL_RGBA32F = 0x8814;
|
||||
|
||||
// constants for glBaseInternalFormat
|
||||
public static int GL_RED = 0x1903;
|
||||
public static int GL_GREEN = 0x1904;
|
||||
public static int GL_BLUE = 0x1905;
|
||||
public static int GL_ALPHA = 0x1906;
|
||||
public static int GL_RGB = 0x1907;
|
||||
public static int GL_RGBA = 0x1908;
|
||||
public static int GL_RG = 0x8227;
|
||||
}
|
||||
|
||||
//from TextureConverter.h
|
||||
public enum QFORMAT
|
||||
{
|
||||
// General formats
|
||||
Q_FORMAT_RGBA_8UI = 1,
|
||||
Q_FORMAT_RGBA_8I,
|
||||
Q_FORMAT_RGB5_A1UI,
|
||||
Q_FORMAT_RGBA_4444,
|
||||
Q_FORMAT_RGBA_16UI,
|
||||
Q_FORMAT_RGBA_16I,
|
||||
Q_FORMAT_RGBA_32UI,
|
||||
Q_FORMAT_RGBA_32I,
|
||||
|
||||
Q_FORMAT_PALETTE_8_RGBA_8888,
|
||||
Q_FORMAT_PALETTE_8_RGBA_5551,
|
||||
Q_FORMAT_PALETTE_8_RGBA_4444,
|
||||
Q_FORMAT_PALETTE_4_RGBA_8888,
|
||||
Q_FORMAT_PALETTE_4_RGBA_5551,
|
||||
Q_FORMAT_PALETTE_4_RGBA_4444,
|
||||
Q_FORMAT_PALETTE_1_RGBA_8888,
|
||||
Q_FORMAT_PALETTE_8_RGB_888,
|
||||
Q_FORMAT_PALETTE_8_RGB_565,
|
||||
Q_FORMAT_PALETTE_4_RGB_888,
|
||||
Q_FORMAT_PALETTE_4_RGB_565,
|
||||
|
||||
Q_FORMAT_R2_GBA10UI,
|
||||
Q_FORMAT_RGB10_A2UI,
|
||||
Q_FORMAT_RGB10_A2I,
|
||||
Q_FORMAT_RGBA_F,
|
||||
Q_FORMAT_RGBA_HF,
|
||||
|
||||
Q_FORMAT_RGB9_E5, // Last five bits are exponent bits (Read following section in GLES3 spec: "3.8.17 Shared Exponent Texture Color Conversion")
|
||||
Q_FORMAT_RGB_8UI,
|
||||
Q_FORMAT_RGB_8I,
|
||||
Q_FORMAT_RGB_565,
|
||||
Q_FORMAT_RGB_16UI,
|
||||
Q_FORMAT_RGB_16I,
|
||||
Q_FORMAT_RGB_32UI,
|
||||
Q_FORMAT_RGB_32I,
|
||||
|
||||
Q_FORMAT_RGB_F,
|
||||
Q_FORMAT_RGB_HF,
|
||||
Q_FORMAT_RGB_11_11_10_F,
|
||||
|
||||
Q_FORMAT_RG_F,
|
||||
Q_FORMAT_RG_HF,
|
||||
Q_FORMAT_RG_32UI,
|
||||
Q_FORMAT_RG_32I,
|
||||
Q_FORMAT_RG_16I,
|
||||
Q_FORMAT_RG_16UI,
|
||||
Q_FORMAT_RG_8I,
|
||||
Q_FORMAT_RG_8UI,
|
||||
Q_FORMAT_RG_S88,
|
||||
|
||||
Q_FORMAT_R_32UI,
|
||||
Q_FORMAT_R_32I,
|
||||
Q_FORMAT_R_F,
|
||||
Q_FORMAT_R_16F,
|
||||
Q_FORMAT_R_16I,
|
||||
Q_FORMAT_R_16UI,
|
||||
Q_FORMAT_R_8I,
|
||||
Q_FORMAT_R_8UI,
|
||||
|
||||
Q_FORMAT_LUMINANCE_ALPHA_88,
|
||||
Q_FORMAT_LUMINANCE_8,
|
||||
Q_FORMAT_ALPHA_8,
|
||||
|
||||
Q_FORMAT_LUMINANCE_ALPHA_F,
|
||||
Q_FORMAT_LUMINANCE_F,
|
||||
Q_FORMAT_ALPHA_F,
|
||||
Q_FORMAT_LUMINANCE_ALPHA_HF,
|
||||
Q_FORMAT_LUMINANCE_HF,
|
||||
Q_FORMAT_ALPHA_HF,
|
||||
Q_FORMAT_DEPTH_16,
|
||||
Q_FORMAT_DEPTH_24,
|
||||
Q_FORMAT_DEPTH_24_STENCIL_8,
|
||||
Q_FORMAT_DEPTH_32,
|
||||
|
||||
Q_FORMAT_BGR_565,
|
||||
Q_FORMAT_BGRA_8888,
|
||||
Q_FORMAT_BGRA_5551,
|
||||
Q_FORMAT_BGRX_8888,
|
||||
Q_FORMAT_BGRA_4444,
|
||||
// Compressed formats
|
||||
Q_FORMAT_ATITC_RGBA,
|
||||
Q_FORMAT_ATC_RGBA_EXPLICIT_ALPHA = Q_FORMAT_ATITC_RGBA,
|
||||
Q_FORMAT_ATITC_RGB,
|
||||
Q_FORMAT_ATC_RGB = Q_FORMAT_ATITC_RGB,
|
||||
Q_FORMAT_ATC_RGBA_INTERPOLATED_ALPHA,
|
||||
Q_FORMAT_ETC1_RGB8,
|
||||
Q_FORMAT_3DC_X,
|
||||
Q_FORMAT_3DC_XY,
|
||||
|
||||
Q_FORMAT_ETC2_RGB8,
|
||||
Q_FORMAT_ETC2_RGBA8,
|
||||
Q_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1,
|
||||
Q_FORMAT_ETC2_SRGB8,
|
||||
Q_FORMAT_ETC2_SRGB8_ALPHA8,
|
||||
Q_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1,
|
||||
Q_FORMAT_EAC_R_SIGNED,
|
||||
Q_FORMAT_EAC_R_UNSIGNED,
|
||||
Q_FORMAT_EAC_RG_SIGNED,
|
||||
Q_FORMAT_EAC_RG_UNSIGNED,
|
||||
|
||||
Q_FORMAT_S3TC_DXT1_RGB,
|
||||
Q_FORMAT_S3TC_DXT1_RGBA,
|
||||
Q_FORMAT_S3TC_DXT3_RGBA,
|
||||
Q_FORMAT_S3TC_DXT5_RGBA,
|
||||
|
||||
// YUV formats
|
||||
Q_FORMAT_AYUV_32,
|
||||
Q_FORMAT_I444_24,
|
||||
Q_FORMAT_YUYV_16,
|
||||
Q_FORMAT_UYVY_16,
|
||||
Q_FORMAT_I420_12,
|
||||
Q_FORMAT_YV12_12,
|
||||
Q_FORMAT_NV21_12,
|
||||
Q_FORMAT_NV12_12,
|
||||
|
||||
// ASTC Format
|
||||
Q_FORMAT_ASTC_8,
|
||||
Q_FORMAT_ASTC_16,
|
||||
};
|
||||
|
||||
public enum texgenpack_texturetype
|
||||
{
|
||||
RGTC1,
|
||||
RGTC2,
|
||||
BPTC_FLOAT,
|
||||
BPTC
|
||||
public enum TextureFormat
|
||||
{
|
||||
Alpha8 = 1,
|
||||
ARGB4444,
|
||||
RGB24,
|
||||
RGBA32,
|
||||
ARGB32,
|
||||
RGB565 = 7,
|
||||
R16 = 9,
|
||||
DXT1,
|
||||
DXT5 = 12,
|
||||
RGBA4444,
|
||||
BGRA32,
|
||||
RHalf,
|
||||
RGHalf,
|
||||
RGBAHalf,
|
||||
RFloat,
|
||||
RGFloat,
|
||||
RGBAFloat,
|
||||
YUY2,
|
||||
RGB9e5Float,
|
||||
BC4 = 26,
|
||||
BC5,
|
||||
BC6H = 24,
|
||||
BC7,
|
||||
DXT1Crunched = 28,
|
||||
DXT5Crunched,
|
||||
PVRTC_RGB2,
|
||||
PVRTC_RGBA2,
|
||||
PVRTC_RGB4,
|
||||
PVRTC_RGBA4,
|
||||
ETC_RGB4,
|
||||
ATC_RGB4,
|
||||
ATC_RGBA8,
|
||||
EAC_R = 41,
|
||||
EAC_R_SIGNED,
|
||||
EAC_RG,
|
||||
EAC_RG_SIGNED,
|
||||
ETC2_RGB,
|
||||
ETC2_RGBA1,
|
||||
ETC2_RGBA8,
|
||||
ASTC_RGB_4x4,
|
||||
ASTC_RGB_5x5,
|
||||
ASTC_RGB_6x6,
|
||||
ASTC_RGB_8x8,
|
||||
ASTC_RGB_10x10,
|
||||
ASTC_RGB_12x12,
|
||||
ASTC_RGBA_4x4,
|
||||
ASTC_RGBA_5x5,
|
||||
ASTC_RGBA_6x6,
|
||||
ASTC_RGBA_8x8,
|
||||
ASTC_RGBA_10x10,
|
||||
ASTC_RGBA_12x12,
|
||||
ETC_RGB4_3DS,
|
||||
ETC_RGBA8_3DS,
|
||||
RG16,
|
||||
R8,
|
||||
ETC_RGB4Crunched,
|
||||
ETC2_RGBA8Crunched,
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Unity_Studio
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class Transform
|
||||
{
|
||||
@@ -17,21 +17,20 @@ namespace Unity_Studio
|
||||
public Transform(AssetPreloadData preloadData)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var a_Stream = preloadData.sourceFile.a_Stream;
|
||||
a_Stream.Position = preloadData.Offset;
|
||||
var reader = preloadData.InitReader();
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
{
|
||||
uint m_ObjectHideFlags = a_Stream.ReadUInt32();
|
||||
uint m_ObjectHideFlags = reader.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
m_GameObject = sourceFile.ReadPPtr();
|
||||
m_LocalRotation = new[] { a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() };
|
||||
m_LocalPosition = new[] { a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() };
|
||||
m_LocalScale = new[] { a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() };
|
||||
int m_ChildrenCount = a_Stream.ReadInt32();
|
||||
m_LocalRotation = new[] { reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() };
|
||||
m_LocalPosition = new[] { reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() };
|
||||
m_LocalScale = new[] { reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() };
|
||||
int m_ChildrenCount = reader.ReadInt32();
|
||||
for (int j = 0; j < m_ChildrenCount; j++)
|
||||
{
|
||||
m_Children.Add(sourceFile.ReadPPtr());
|
||||
102
AssetStudio/Classes/VideoClip.cs
Normal file
102
AssetStudio/Classes/VideoClip.cs
Normal file
@@ -0,0 +1,102 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
class VideoClip
|
||||
{
|
||||
public string m_Name;
|
||||
public byte[] m_VideoData;
|
||||
|
||||
public VideoClip(AssetPreloadData preloadData, bool readSwitch)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var reader = preloadData.InitReader();
|
||||
|
||||
m_Name = reader.ReadAlignedString();
|
||||
var m_OriginalPath = reader.ReadAlignedString();
|
||||
var m_ProxyWidth = reader.ReadUInt32();
|
||||
var m_ProxyHeight = reader.ReadUInt32();
|
||||
var Width = reader.ReadUInt32();
|
||||
var Height = reader.ReadUInt32();
|
||||
if (sourceFile.version[0] >= 2017)//2017.x and up
|
||||
{
|
||||
var m_PixelAspecRatioNum = reader.ReadUInt32();
|
||||
var m_PixelAspecRatioDen = reader.ReadUInt32();
|
||||
}
|
||||
var m_FrameRate = reader.ReadDouble();
|
||||
var m_FrameCount = reader.ReadUInt64();
|
||||
var m_Format = reader.ReadInt32();
|
||||
//m_AudioChannelCount
|
||||
var size = reader.ReadInt32();
|
||||
reader.Position += size * 2;
|
||||
reader.AlignStream(4);
|
||||
//m_AudioSampleRate
|
||||
size = reader.ReadInt32();
|
||||
reader.Position += size * 4;
|
||||
//m_AudioLanguage
|
||||
size = reader.ReadInt32();
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
reader.ReadAlignedString();
|
||||
}
|
||||
//StreamedResource m_ExternalResources
|
||||
var m_Source = reader.ReadAlignedString();
|
||||
var m_Offset = reader.ReadUInt64();
|
||||
var m_Size = reader.ReadUInt64();
|
||||
var m_HasSplitAlpha = reader.ReadBoolean();
|
||||
|
||||
if (readSwitch)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(m_Source))
|
||||
{
|
||||
var resourceFileName = Path.GetFileName(m_Source);
|
||||
var resourceFilePath = Path.GetDirectoryName(sourceFile.filePath) + "\\" + resourceFileName;
|
||||
if (!File.Exists(resourceFilePath))
|
||||
{
|
||||
var findFiles = Directory.GetFiles(Path.GetDirectoryName(sourceFile.filePath), resourceFileName, SearchOption.AllDirectories);
|
||||
if (findFiles.Length > 0)
|
||||
{
|
||||
resourceFilePath = findFiles[0];
|
||||
}
|
||||
}
|
||||
if (File.Exists(resourceFilePath))
|
||||
{
|
||||
using (var resourceReader = new BinaryReader(File.OpenRead(resourceFilePath)))
|
||||
{
|
||||
resourceReader.BaseStream.Position = (long)m_Offset;
|
||||
m_VideoData = resourceReader.ReadBytes((int)m_Size);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Studio.resourceFileReaders.TryGetValue(resourceFileName.ToUpper(), out var resourceReader))
|
||||
{
|
||||
resourceReader.Position = (long)m_Offset;
|
||||
m_VideoData = resourceReader.ReadBytes((int)m_Size);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show($"can't find the resource file {resourceFileName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_Size > 0)
|
||||
m_VideoData = reader.ReadBytes((int)m_Size);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
preloadData.extension = Path.GetExtension(m_OriginalPath);
|
||||
preloadData.Text = m_Name;
|
||||
preloadData.fullSize = preloadData.Size + (int)m_Size;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Unity_Studio
|
||||
namespace AssetStudio
|
||||
{
|
||||
partial class ExportOptions
|
||||
{
|
||||
@@ -54,12 +54,26 @@
|
||||
this.topng = new System.Windows.Forms.RadioButton();
|
||||
this.tobmp = new System.Windows.Forms.RadioButton();
|
||||
this.converttexture = new System.Windows.Forms.CheckBox();
|
||||
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||
this.compatibility = new System.Windows.Forms.CheckBox();
|
||||
this.flatInbetween = new System.Windows.Forms.CheckBox();
|
||||
this.boneSize = new System.Windows.Forms.NumericUpDown();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.skins = new System.Windows.Forms.CheckBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.filterPrecision = new System.Windows.Forms.NumericUpDown();
|
||||
this.allBones = new System.Windows.Forms.CheckBox();
|
||||
this.allFrames = new System.Windows.Forms.CheckBox();
|
||||
this.EulerFilter = new System.Windows.Forms.CheckBox();
|
||||
this.includeBox.SuspendLayout();
|
||||
this.geometryBox.SuspendLayout();
|
||||
this.advancedBox.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.scaleFactor)).BeginInit();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.panel1.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.boneSize)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.filterPrecision)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// includeBox
|
||||
@@ -204,7 +218,7 @@
|
||||
this.advancedBox.Controls.Add(this.upAxis);
|
||||
this.advancedBox.Controls.Add(this.scaleFactor);
|
||||
this.advancedBox.Controls.Add(this.scaleLabel);
|
||||
this.advancedBox.Location = new System.Drawing.Point(12, 284);
|
||||
this.advancedBox.Location = new System.Drawing.Point(12, 285);
|
||||
this.advancedBox.Name = "advancedBox";
|
||||
this.advancedBox.Size = new System.Drawing.Size(249, 78);
|
||||
this.advancedBox.TabIndex = 5;
|
||||
@@ -260,7 +274,7 @@
|
||||
//
|
||||
// fbxOKbutton
|
||||
//
|
||||
this.fbxOKbutton.Location = new System.Drawing.Point(332, 364);
|
||||
this.fbxOKbutton.Location = new System.Drawing.Point(339, 369);
|
||||
this.fbxOKbutton.Name = "fbxOKbutton";
|
||||
this.fbxOKbutton.Size = new System.Drawing.Size(75, 21);
|
||||
this.fbxOKbutton.TabIndex = 6;
|
||||
@@ -271,7 +285,7 @@
|
||||
// fbxCancel
|
||||
//
|
||||
this.fbxCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.fbxCancel.Location = new System.Drawing.Point(420, 364);
|
||||
this.fbxCancel.Location = new System.Drawing.Point(420, 369);
|
||||
this.fbxCancel.Name = "fbxCancel";
|
||||
this.fbxCancel.Size = new System.Drawing.Size(75, 21);
|
||||
this.fbxCancel.TabIndex = 7;
|
||||
@@ -282,7 +296,7 @@
|
||||
// showExpOpt
|
||||
//
|
||||
this.showExpOpt.AutoSize = true;
|
||||
this.showExpOpt.Location = new System.Drawing.Point(12, 367);
|
||||
this.showExpOpt.Location = new System.Drawing.Point(12, 372);
|
||||
this.showExpOpt.Name = "showExpOpt";
|
||||
this.showExpOpt.Size = new System.Drawing.Size(222, 16);
|
||||
this.showExpOpt.TabIndex = 8;
|
||||
@@ -296,7 +310,7 @@
|
||||
this.groupBox1.Controls.Add(this.converttexture);
|
||||
this.groupBox1.Location = new System.Drawing.Point(267, 12);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(228, 349);
|
||||
this.groupBox1.Size = new System.Drawing.Size(228, 140);
|
||||
this.groupBox1.TabIndex = 9;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Convert";
|
||||
@@ -306,7 +320,7 @@
|
||||
this.convertAudio.AutoSize = true;
|
||||
this.convertAudio.Checked = true;
|
||||
this.convertAudio.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.convertAudio.Location = new System.Drawing.Point(8, 81);
|
||||
this.convertAudio.Location = new System.Drawing.Point(6, 78);
|
||||
this.convertAudio.Name = "convertAudio";
|
||||
this.convertAudio.Size = new System.Drawing.Size(198, 28);
|
||||
this.convertAudio.TabIndex = 6;
|
||||
@@ -360,20 +374,152 @@
|
||||
this.converttexture.AutoSize = true;
|
||||
this.converttexture.Checked = true;
|
||||
this.converttexture.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.converttexture.Location = new System.Drawing.Point(8, 20);
|
||||
this.converttexture.Location = new System.Drawing.Point(6, 20);
|
||||
this.converttexture.Name = "converttexture";
|
||||
this.converttexture.Size = new System.Drawing.Size(192, 16);
|
||||
this.converttexture.TabIndex = 1;
|
||||
this.converttexture.Text = "Convert Texture (If support)";
|
||||
this.converttexture.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
this.groupBox2.Controls.Add(this.compatibility);
|
||||
this.groupBox2.Controls.Add(this.flatInbetween);
|
||||
this.groupBox2.Controls.Add(this.boneSize);
|
||||
this.groupBox2.Controls.Add(this.label2);
|
||||
this.groupBox2.Controls.Add(this.skins);
|
||||
this.groupBox2.Controls.Add(this.label1);
|
||||
this.groupBox2.Controls.Add(this.filterPrecision);
|
||||
this.groupBox2.Controls.Add(this.allBones);
|
||||
this.groupBox2.Controls.Add(this.allFrames);
|
||||
this.groupBox2.Controls.Add(this.EulerFilter);
|
||||
this.groupBox2.Location = new System.Drawing.Point(267, 158);
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
this.groupBox2.Size = new System.Drawing.Size(228, 205);
|
||||
this.groupBox2.TabIndex = 11;
|
||||
this.groupBox2.TabStop = false;
|
||||
this.groupBox2.Text = "Animator";
|
||||
//
|
||||
// compatibility
|
||||
//
|
||||
this.compatibility.AutoSize = true;
|
||||
this.compatibility.Location = new System.Drawing.Point(6, 177);
|
||||
this.compatibility.Name = "compatibility";
|
||||
this.compatibility.Size = new System.Drawing.Size(102, 16);
|
||||
this.compatibility.TabIndex = 13;
|
||||
this.compatibility.Text = "compatibility";
|
||||
this.compatibility.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// flatInbetween
|
||||
//
|
||||
this.flatInbetween.AutoSize = true;
|
||||
this.flatInbetween.Location = new System.Drawing.Point(6, 155);
|
||||
this.flatInbetween.Name = "flatInbetween";
|
||||
this.flatInbetween.Size = new System.Drawing.Size(102, 16);
|
||||
this.flatInbetween.TabIndex = 12;
|
||||
this.flatInbetween.Text = "flatInbetween";
|
||||
this.flatInbetween.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// boneSize
|
||||
//
|
||||
this.boneSize.Location = new System.Drawing.Point(65, 128);
|
||||
this.boneSize.Name = "boneSize";
|
||||
this.boneSize.Size = new System.Drawing.Size(46, 21);
|
||||
this.boneSize.TabIndex = 11;
|
||||
this.boneSize.Value = new decimal(new int[] {
|
||||
10,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(6, 130);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(53, 12);
|
||||
this.label2.TabIndex = 10;
|
||||
this.label2.Text = "boneSize";
|
||||
//
|
||||
// skins
|
||||
//
|
||||
this.skins.AutoSize = true;
|
||||
this.skins.Checked = true;
|
||||
this.skins.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.skins.Location = new System.Drawing.Point(6, 105);
|
||||
this.skins.Name = "skins";
|
||||
this.skins.Size = new System.Drawing.Size(54, 16);
|
||||
this.skins.TabIndex = 8;
|
||||
this.skins.Text = "skins";
|
||||
this.skins.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(26, 39);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(95, 12);
|
||||
this.label1.TabIndex = 7;
|
||||
this.label1.Text = "filterPrecision";
|
||||
//
|
||||
// filterPrecision
|
||||
//
|
||||
this.filterPrecision.DecimalPlaces = 2;
|
||||
this.filterPrecision.Increment = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
131072});
|
||||
this.filterPrecision.Location = new System.Drawing.Point(127, 37);
|
||||
this.filterPrecision.Name = "filterPrecision";
|
||||
this.filterPrecision.Size = new System.Drawing.Size(51, 21);
|
||||
this.filterPrecision.TabIndex = 6;
|
||||
this.filterPrecision.Value = new decimal(new int[] {
|
||||
25,
|
||||
0,
|
||||
0,
|
||||
131072});
|
||||
//
|
||||
// allBones
|
||||
//
|
||||
this.allBones.AutoSize = true;
|
||||
this.allBones.Checked = true;
|
||||
this.allBones.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.allBones.Location = new System.Drawing.Point(6, 83);
|
||||
this.allBones.Name = "allBones";
|
||||
this.allBones.Size = new System.Drawing.Size(72, 16);
|
||||
this.allBones.TabIndex = 5;
|
||||
this.allBones.Text = "allBones";
|
||||
this.allBones.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// allFrames
|
||||
//
|
||||
this.allFrames.AutoSize = true;
|
||||
this.allFrames.Location = new System.Drawing.Point(6, 61);
|
||||
this.allFrames.Name = "allFrames";
|
||||
this.allFrames.Size = new System.Drawing.Size(78, 16);
|
||||
this.allFrames.TabIndex = 4;
|
||||
this.allFrames.Text = "allFrames";
|
||||
this.allFrames.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// EulerFilter
|
||||
//
|
||||
this.EulerFilter.AutoSize = true;
|
||||
this.EulerFilter.Location = new System.Drawing.Point(6, 20);
|
||||
this.EulerFilter.Name = "EulerFilter";
|
||||
this.EulerFilter.Size = new System.Drawing.Size(90, 16);
|
||||
this.EulerFilter.TabIndex = 3;
|
||||
this.EulerFilter.Text = "EulerFilter";
|
||||
this.EulerFilter.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// ExportOptions
|
||||
//
|
||||
this.AcceptButton = this.fbxOKbutton;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.fbxCancel;
|
||||
this.ClientSize = new System.Drawing.Size(513, 392);
|
||||
this.ClientSize = new System.Drawing.Size(508, 398);
|
||||
this.Controls.Add(this.groupBox2);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Controls.Add(this.showExpOpt);
|
||||
this.Controls.Add(this.fbxCancel);
|
||||
@@ -399,6 +545,10 @@
|
||||
this.groupBox1.PerformLayout();
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.panel1.PerformLayout();
|
||||
this.groupBox2.ResumeLayout(false);
|
||||
this.groupBox2.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.boneSize)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.filterPrecision)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@@ -432,5 +582,16 @@
|
||||
private System.Windows.Forms.RadioButton tobmp;
|
||||
private System.Windows.Forms.CheckBox convertAudio;
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
private System.Windows.Forms.GroupBox groupBox2;
|
||||
private System.Windows.Forms.CheckBox compatibility;
|
||||
private System.Windows.Forms.CheckBox flatInbetween;
|
||||
private System.Windows.Forms.NumericUpDown boneSize;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.CheckBox skins;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.NumericUpDown filterPrecision;
|
||||
private System.Windows.Forms.CheckBox allBones;
|
||||
private System.Windows.Forms.CheckBox allFrames;
|
||||
private System.Windows.Forms.CheckBox EulerFilter;
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Unity_Studio
|
||||
namespace AssetStudio
|
||||
{
|
||||
public partial class ExportOptions : Form
|
||||
{
|
||||
@@ -36,6 +36,14 @@ namespace Unity_Studio
|
||||
break;
|
||||
}
|
||||
}
|
||||
EulerFilter.Checked = (bool)Properties.Settings.Default["EulerFilter"];
|
||||
filterPrecision.Value = (decimal)Properties.Settings.Default["filterPrecision"];
|
||||
allFrames.Checked = (bool)Properties.Settings.Default["allFrames"];
|
||||
allBones.Checked = (bool)Properties.Settings.Default["allBones"];
|
||||
skins.Checked = (bool)Properties.Settings.Default["skins"];
|
||||
boneSize.Value = (decimal)Properties.Settings.Default["boneSize"];
|
||||
flatInbetween.Checked = (bool)Properties.Settings.Default["flatInbetween"];
|
||||
compatibility.Checked = (bool)Properties.Settings.Default["compatibility"];
|
||||
}
|
||||
|
||||
private void exportOpnions_CheckedChanged(object sender, EventArgs e)
|
||||
@@ -63,6 +71,14 @@ namespace Unity_Studio
|
||||
break;
|
||||
}
|
||||
}
|
||||
Properties.Settings.Default["EulerFilter"] = EulerFilter.Checked;
|
||||
Properties.Settings.Default["filterPrecision"] = filterPrecision.Value;
|
||||
Properties.Settings.Default["allFrames"] = allFrames.Checked;
|
||||
Properties.Settings.Default["allBones"] = allBones.Checked;
|
||||
Properties.Settings.Default["skins"] = skins.Checked;
|
||||
Properties.Settings.Default["boneSize"] = boneSize.Value;
|
||||
Properties.Settings.Default["flatInbetween"] = flatInbetween.Checked;
|
||||
Properties.Settings.Default["compatibility"] = compatibility.Checked;
|
||||
Properties.Settings.Default.Save();
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Unity_Studio
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class GOHierarchy : TreeView
|
||||
{
|
||||
BIN
AssetStudio/Library/BrotliSharpLib.dll
Normal file
BIN
AssetStudio/Library/BrotliSharpLib.dll
Normal file
Binary file not shown.
BIN
AssetStudio/Library/SharpDX.Mathematics.dll
Normal file
BIN
AssetStudio/Library/SharpDX.Mathematics.dll
Normal file
Binary file not shown.
BIN
AssetStudio/Library/SharpDX.dll
Normal file
BIN
AssetStudio/Library/SharpDX.dll
Normal file
Binary file not shown.
BIN
AssetStudio/Library/x64/libfbxsdk.dll
Normal file
BIN
AssetStudio/Library/x64/libfbxsdk.dll
Normal file
Binary file not shown.
BIN
AssetStudio/Library/x86/libfbxsdk.dll
Normal file
BIN
AssetStudio/Library/x86/libfbxsdk.dll
Normal file
Binary file not shown.
@@ -31,9 +31,20 @@ namespace Lz4
|
||||
inBufEnd = DecBufLen;
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
input = null;
|
||||
try
|
||||
{
|
||||
if (disposing && input != null)
|
||||
{
|
||||
input.Close();
|
||||
}
|
||||
input = null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
|
||||
private long inputLength;
|
||||
@@ -500,15 +511,12 @@ namespace Lz4
|
||||
{
|
||||
}
|
||||
|
||||
public override long Length
|
||||
{
|
||||
get { throw new NotSupportedException(); }
|
||||
}
|
||||
public override long Length => throw new NotSupportedException();
|
||||
|
||||
public override long Position
|
||||
{
|
||||
get { throw new NotSupportedException(); }
|
||||
set { throw new NotSupportedException(); }
|
||||
get => throw new NotSupportedException();
|
||||
set => throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
@@ -4,7 +4,7 @@ using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Unity_Studio
|
||||
namespace AssetStudio
|
||||
{
|
||||
class OpenFolderDialog
|
||||
{
|
||||
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Unity_Studio
|
||||
namespace AssetStudio
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
@@ -15,7 +15,7 @@ namespace Unity_Studio
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new UnityStudioForm());
|
||||
Application.Run(new AssetStudioForm());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,11 @@ using System.Runtime.InteropServices;
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Unity Studio")]
|
||||
[assembly: AssemblyDescription("Unity Studio is a tool for exploring, extracting and exporting assets from Unity games and apps. It has been tested with Unity builds from most platforms, ranging from Web, PC, Linux, MacOS to Xbox360, PS3, Android and iOS, and it is currently maintained to be compatible with Unity builds from 2.5 up to the 2017.3 version.")]
|
||||
[assembly: AssemblyTitle("AssetStudio")]
|
||||
[assembly: AssemblyDescription("AssetStudio is a tool for exploring, extracting and exporting assets and assetBundles.")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Unity Studio")]
|
||||
[assembly: AssemblyProduct("AssetStudio")]
|
||||
[assembly: AssemblyCopyright("")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
@@ -8,7 +8,7 @@
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Unity_Studio.Properties {
|
||||
namespace AssetStudio.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Unity_Studio.Properties {
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Unity_Studio.Properties.Resources", typeof(Resources).Assembly);
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AssetStudio.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
@@ -127,16 +127,6 @@ namespace Unity_Studio.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。
|
||||
/// </summary>
|
||||
internal static System.Drawing.Icon unity {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("unity", resourceCulture);
|
||||
return ((System.Drawing.Icon)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 #version 140
|
||||
///
|
||||
@@ -162,9 +162,6 @@ void main()
|
||||
<data name="preview" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\preview.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="unity" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\unity.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="vs" xml:space="preserve">
|
||||
<value>#version 140
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Unity_Studio.Properties {
|
||||
namespace AssetStudio.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.5.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.6.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
@@ -238,5 +238,101 @@ namespace Unity_Studio.Properties {
|
||||
this["displayOriginalName"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("False")]
|
||||
public bool EulerFilter {
|
||||
get {
|
||||
return ((bool)(this["EulerFilter"]));
|
||||
}
|
||||
set {
|
||||
this["EulerFilter"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("0.25")]
|
||||
public decimal filterPrecision {
|
||||
get {
|
||||
return ((decimal)(this["filterPrecision"]));
|
||||
}
|
||||
set {
|
||||
this["filterPrecision"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("False")]
|
||||
public bool allFrames {
|
||||
get {
|
||||
return ((bool)(this["allFrames"]));
|
||||
}
|
||||
set {
|
||||
this["allFrames"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("True")]
|
||||
public bool allBones {
|
||||
get {
|
||||
return ((bool)(this["allBones"]));
|
||||
}
|
||||
set {
|
||||
this["allBones"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("True")]
|
||||
public bool skins {
|
||||
get {
|
||||
return ((bool)(this["skins"]));
|
||||
}
|
||||
set {
|
||||
this["skins"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("10")]
|
||||
public decimal boneSize {
|
||||
get {
|
||||
return ((decimal)(this["boneSize"]));
|
||||
}
|
||||
set {
|
||||
this["boneSize"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("False")]
|
||||
public bool flatInbetween {
|
||||
get {
|
||||
return ((bool)(this["flatInbetween"]));
|
||||
}
|
||||
set {
|
||||
this["flatInbetween"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("False")]
|
||||
public bool compatibility {
|
||||
get {
|
||||
return ((bool)(this["compatibility"]));
|
||||
}
|
||||
set {
|
||||
this["compatibility"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Unity_Studio.Properties" GeneratedClassName="Settings">
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="AssetStudio.Properties" GeneratedClassName="Settings">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="displayAll" Type="System.Boolean" Scope="User">
|
||||
@@ -56,5 +56,29 @@
|
||||
<Setting Name="displayOriginalName" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
<Setting Name="EulerFilter" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
<Setting Name="filterPrecision" Type="System.Decimal" Scope="User">
|
||||
<Value Profile="(Default)">0.25</Value>
|
||||
</Setting>
|
||||
<Setting Name="allFrames" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
<Setting Name="allBones" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="skins" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="boneSize" Type="System.Decimal" Scope="User">
|
||||
<Value Profile="(Default)">10</Value>
|
||||
</Setting>
|
||||
<Setting Name="flatInbetween" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
<Setting Name="compatibility" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
BIN
AssetStudio/Resources/preview.png
Normal file
BIN
AssetStudio/Resources/preview.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.9 KiB |
@@ -4,13 +4,14 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Unity_Studio
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class AssetPreloadData : ListViewItem
|
||||
{
|
||||
public long m_PathID;
|
||||
public uint Offset;
|
||||
public int Size;
|
||||
public ClassIDReference Type;
|
||||
public int Type1;
|
||||
public int Type2;
|
||||
|
||||
@@ -21,5 +22,12 @@ namespace Unity_Studio
|
||||
|
||||
public AssetsFile sourceFile;
|
||||
public string uniqueID;
|
||||
|
||||
public EndianBinaryReader InitReader()
|
||||
{
|
||||
var reader = sourceFile.assetsFileReader;
|
||||
reader.Position = Offset;
|
||||
return reader;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,14 +6,15 @@ using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Unity_Studio
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class AssetsFile
|
||||
{
|
||||
public EndianBinaryReader a_Stream;
|
||||
public EndianBinaryReader assetsFileReader;
|
||||
public string filePath;
|
||||
public string bundlePath;
|
||||
public string parentPath;
|
||||
public string fileName;
|
||||
public string upperFileName;
|
||||
public int fileGen;
|
||||
public bool valid;
|
||||
public string m_Version = "2.5.0f5";
|
||||
@@ -26,17 +27,16 @@ namespace Unity_Studio
|
||||
public Dictionary<long, Transform> TransformList = new Dictionary<long, Transform>();
|
||||
|
||||
public List<AssetPreloadData> exportableAssets = new List<AssetPreloadData>();
|
||||
public List<UnityShared> sharedAssetsList = new List<UnityShared>() { new UnityShared() };
|
||||
public List<SharedAssets> sharedAssetsList = new List<SharedAssets> { new SharedAssets() };
|
||||
|
||||
public SortedDictionary<int, ClassStruct> ClassStructures = new SortedDictionary<int, ClassStruct>();
|
||||
|
||||
private bool baseDefinitions;
|
||||
private List<int[]> classIDs = new List<int[]>();//use for 5.5.0
|
||||
|
||||
public static string[] buildTypeSplit = { ".", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||
|
||||
#region cmmon string
|
||||
private static Dictionary<int, string> baseStrings = new Dictionary<int, string>()
|
||||
private static Dictionary<int, string> baseStrings = new Dictionary<int, string>
|
||||
{
|
||||
{0, "AABB"},
|
||||
{5, "AnimationClip"},
|
||||
@@ -142,54 +142,55 @@ namespace Unity_Studio
|
||||
};
|
||||
#endregion
|
||||
|
||||
public class UnityShared
|
||||
public class SharedAssets
|
||||
{
|
||||
public int Index = -1; //actual index in main list
|
||||
public int Index = -2; //-2 - Prepare, -1 - Missing
|
||||
public string aName = "";
|
||||
public string fileName = "";
|
||||
}
|
||||
|
||||
public AssetsFile(string fullName, EndianBinaryReader fileStream)
|
||||
public AssetsFile(string fullName, EndianBinaryReader reader)
|
||||
{
|
||||
a_Stream = fileStream;
|
||||
assetsFileReader = reader;
|
||||
filePath = fullName;
|
||||
fileName = Path.GetFileName(fullName);
|
||||
upperFileName = fileName.ToUpper();
|
||||
try
|
||||
{
|
||||
int tableSize = a_Stream.ReadInt32();
|
||||
int dataEnd = a_Stream.ReadInt32();
|
||||
fileGen = a_Stream.ReadInt32();
|
||||
uint dataOffset = a_Stream.ReadUInt32();
|
||||
sharedAssetsList[0].fileName = Path.GetFileName(fullName); //reference itself because sharedFileIDs start from 1
|
||||
int tableSize = assetsFileReader.ReadInt32();
|
||||
int dataEnd = assetsFileReader.ReadInt32();
|
||||
fileGen = assetsFileReader.ReadInt32();
|
||||
uint dataOffset = assetsFileReader.ReadUInt32();
|
||||
sharedAssetsList[0].fileName = fileName; //reference itself because sharedFileIDs start from 1
|
||||
|
||||
switch (fileGen)
|
||||
{
|
||||
case 6: //2.5.0 - 2.6.1
|
||||
{
|
||||
a_Stream.Position = (dataEnd - tableSize);
|
||||
a_Stream.Position += 1;
|
||||
assetsFileReader.Position = (dataEnd - tableSize);
|
||||
assetsFileReader.Position += 1;
|
||||
break;
|
||||
}
|
||||
case 7: //3.0.0 beta
|
||||
{
|
||||
a_Stream.Position = (dataEnd - tableSize);
|
||||
a_Stream.Position += 1;
|
||||
m_Version = a_Stream.ReadStringToNull();
|
||||
assetsFileReader.Position = (dataEnd - tableSize);
|
||||
assetsFileReader.Position += 1;
|
||||
m_Version = assetsFileReader.ReadStringToNull();
|
||||
break;
|
||||
}
|
||||
case 8: //3.0.0 - 3.4.2
|
||||
{
|
||||
a_Stream.Position = (dataEnd - tableSize);
|
||||
a_Stream.Position += 1;
|
||||
m_Version = a_Stream.ReadStringToNull();
|
||||
platform = a_Stream.ReadInt32();
|
||||
assetsFileReader.Position = (dataEnd - tableSize);
|
||||
assetsFileReader.Position += 1;
|
||||
m_Version = assetsFileReader.ReadStringToNull();
|
||||
platform = assetsFileReader.ReadInt32();
|
||||
break;
|
||||
}
|
||||
case 9: //3.5.0 - 4.6.x
|
||||
{
|
||||
a_Stream.Position += 4; //azero
|
||||
m_Version = a_Stream.ReadStringToNull();
|
||||
platform = a_Stream.ReadInt32();
|
||||
assetsFileReader.Position += 4; //azero
|
||||
m_Version = assetsFileReader.ReadStringToNull();
|
||||
platform = assetsFileReader.ReadInt32();
|
||||
break;
|
||||
}
|
||||
case 14: //5.0.0 beta and final
|
||||
@@ -197,15 +198,15 @@ namespace Unity_Studio
|
||||
case 16: //??.. no sure
|
||||
case 17: //5.5.0 and up
|
||||
{
|
||||
a_Stream.Position += 4; //azero
|
||||
m_Version = a_Stream.ReadStringToNull();
|
||||
platform = a_Stream.ReadInt32();
|
||||
baseDefinitions = a_Stream.ReadBoolean();
|
||||
assetsFileReader.Position += 4; //azero
|
||||
m_Version = assetsFileReader.ReadStringToNull();
|
||||
platform = assetsFileReader.ReadInt32();
|
||||
baseDefinitions = assetsFileReader.ReadBoolean();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
//MessageBox.Show("Unsupported Unity version!" + fileGen, "Unity Studio Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
//MessageBox.Show("Unsupported version!" + fileGen, "AssetStudio Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -215,68 +216,21 @@ namespace Unity_Studio
|
||||
byte[] b32 = BitConverter.GetBytes(platform);
|
||||
Array.Reverse(b32);
|
||||
platform = BitConverter.ToInt32(b32, 0);
|
||||
a_Stream.endian = EndianType.LittleEndian;
|
||||
assetsFileReader.endian = EndianType.LittleEndian;
|
||||
}
|
||||
|
||||
switch (platform)
|
||||
{
|
||||
case -2:
|
||||
platformStr = "Unity Package";
|
||||
break;
|
||||
case 4:
|
||||
platformStr = "OSX";
|
||||
break;
|
||||
case 5:
|
||||
platformStr = "PC";
|
||||
break;
|
||||
case 6:
|
||||
platformStr = "Web";
|
||||
break;
|
||||
case 7:
|
||||
platformStr = "Web streamed";
|
||||
break;
|
||||
case 9:
|
||||
platformStr = "iOS";
|
||||
break;
|
||||
case 10:
|
||||
platformStr = "PS3";
|
||||
break;
|
||||
case 11:
|
||||
platformStr = "Xbox 360";
|
||||
break;
|
||||
case 13:
|
||||
platformStr = "Android";
|
||||
break;
|
||||
case 16:
|
||||
platformStr = "Google NaCl";
|
||||
break;
|
||||
case 19:
|
||||
platformStr = "CollabPreview";
|
||||
break;
|
||||
case 21:
|
||||
platformStr = "WP8";
|
||||
break;
|
||||
case 25:
|
||||
platformStr = "Linux";
|
||||
break;
|
||||
case 29:
|
||||
platformStr = "Wii U";
|
||||
break;
|
||||
default:
|
||||
platformStr = "Unknown Platform";
|
||||
break;
|
||||
}
|
||||
platformStr = Enum.IsDefined(typeof(BuildTarget), platform) ? ((BuildTarget)platform).ToString() : "Unknown Platform";
|
||||
|
||||
int baseCount = a_Stream.ReadInt32();
|
||||
int baseCount = assetsFileReader.ReadInt32();
|
||||
for (int i = 0; i < baseCount; i++)
|
||||
{
|
||||
if (fileGen < 14)
|
||||
{
|
||||
int classID = a_Stream.ReadInt32();
|
||||
string baseType = a_Stream.ReadStringToNull();
|
||||
string baseName = a_Stream.ReadStringToNull();
|
||||
a_Stream.Position += 20;
|
||||
int memberCount = a_Stream.ReadInt32();
|
||||
int classID = assetsFileReader.ReadInt32();
|
||||
string baseType = assetsFileReader.ReadStringToNull();
|
||||
string baseName = assetsFileReader.ReadStringToNull();
|
||||
assetsFileReader.Position += 20;
|
||||
int memberCount = assetsFileReader.ReadInt32();
|
||||
|
||||
var cb = new List<ClassMember>();
|
||||
for (int m = 0; m < memberCount; m++)
|
||||
@@ -284,7 +238,7 @@ namespace Unity_Studio
|
||||
readBase(cb, 1);
|
||||
}
|
||||
|
||||
var aClass = new ClassStruct() { ID = classID, Text = (baseType + " " + baseName), members = cb };
|
||||
var aClass = new ClassStruct { ID = classID, Text = (baseType + " " + baseName), members = cb };
|
||||
aClass.SubItems.Add(classID.ToString());
|
||||
ClassStructures.Add(classID, aClass);
|
||||
}
|
||||
@@ -296,10 +250,10 @@ namespace Unity_Studio
|
||||
|
||||
if (fileGen >= 7 && fileGen < 14)
|
||||
{
|
||||
a_Stream.Position += 4; //azero
|
||||
assetsFileReader.Position += 4; //azero
|
||||
}
|
||||
|
||||
int assetCount = a_Stream.ReadInt32();
|
||||
int assetCount = assetsFileReader.ReadInt32();
|
||||
|
||||
#region asset preload table
|
||||
string assetIDfmt = "D" + assetCount.ToString().Length; //format for unique ID
|
||||
@@ -309,41 +263,43 @@ namespace Unity_Studio
|
||||
//each table entry is aligned individually, not the whole table
|
||||
if (fileGen >= 14)
|
||||
{
|
||||
a_Stream.AlignStream(4);
|
||||
assetsFileReader.AlignStream(4);
|
||||
}
|
||||
|
||||
AssetPreloadData asset = new AssetPreloadData();
|
||||
asset.m_PathID = fileGen < 14 ? a_Stream.ReadInt32() : a_Stream.ReadInt64();
|
||||
asset.Offset = a_Stream.ReadUInt32();
|
||||
asset.m_PathID = fileGen < 14 ? assetsFileReader.ReadInt32() : assetsFileReader.ReadInt64();
|
||||
asset.Offset = assetsFileReader.ReadUInt32();
|
||||
asset.Offset += dataOffset;
|
||||
asset.Size = a_Stream.ReadInt32();
|
||||
asset.Size = assetsFileReader.ReadInt32();
|
||||
if (fileGen > 15)
|
||||
{
|
||||
int index = a_Stream.ReadInt32();
|
||||
int index = assetsFileReader.ReadInt32();
|
||||
asset.Type1 = classIDs[index][0];
|
||||
asset.Type2 = classIDs[index][1];
|
||||
}
|
||||
else
|
||||
{
|
||||
asset.Type1 = a_Stream.ReadInt32();
|
||||
asset.Type2 = a_Stream.ReadUInt16();
|
||||
a_Stream.Position += 2;
|
||||
asset.Type1 = assetsFileReader.ReadInt32();
|
||||
asset.Type2 = assetsFileReader.ReadUInt16();
|
||||
assetsFileReader.Position += 2;
|
||||
}
|
||||
if (fileGen == 15)
|
||||
{
|
||||
byte unknownByte = a_Stream.ReadByte();
|
||||
byte unknownByte = assetsFileReader.ReadByte();
|
||||
//this is a single byte, not an int32
|
||||
//the next entry is aligned after this
|
||||
//but not the last!
|
||||
}
|
||||
|
||||
if (ClassIDReference.Names.TryGetValue(asset.Type2, out var typeString))
|
||||
if (Enum.IsDefined(typeof(ClassIDReference), asset.Type2))
|
||||
{
|
||||
asset.TypeString = typeString;
|
||||
asset.Type = (ClassIDReference)asset.Type2;
|
||||
asset.TypeString = asset.Type.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
asset.TypeString = "Unknown Type " + asset.Type2;
|
||||
asset.Type = ClassIDReference.UnknownType;
|
||||
asset.TypeString = "UnknownType " + asset.Type2;
|
||||
}
|
||||
|
||||
asset.uniqueID = i.ToString(assetIDfmt);
|
||||
@@ -353,23 +309,22 @@ namespace Unity_Studio
|
||||
|
||||
preloadTable.Add(asset.m_PathID, asset);
|
||||
|
||||
#region read BuildSettings to get version for unity 2.x files
|
||||
if (asset.Type2 == 141 && fileGen == 6)
|
||||
#region read BuildSettings to get version for version 2.x files
|
||||
if (asset.Type == ClassIDReference.BuildSettings && fileGen == 6)
|
||||
{
|
||||
long nextAsset = a_Stream.Position;
|
||||
long nextAsset = assetsFileReader.Position;
|
||||
|
||||
BuildSettings BSettings = new BuildSettings(asset);
|
||||
m_Version = BSettings.m_Version;
|
||||
|
||||
a_Stream.Position = nextAsset;
|
||||
assetsFileReader.Position = nextAsset;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
||||
buildType = m_Version.Split(buildTypeSplit, StringSplitOptions.RemoveEmptyEntries);
|
||||
var strver = from Match m in Regex.Matches(m_Version, @"[0-9]") select m.Value;
|
||||
version = Array.ConvertAll(strver.ToArray(), int.Parse);
|
||||
buildType = Regex.Replace(m_Version, @"\d", "").Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries);
|
||||
version = Regex.Matches(m_Version, @"\d").Cast<Match>().Select(m => int.Parse(m.Value)).ToArray();
|
||||
if (version[0] == 2 && version[1] == 0 && version[2] == 1 && version[3] == 7)//2017.x
|
||||
{
|
||||
var nversion = new int[version.Length - 3];
|
||||
@@ -380,23 +335,23 @@ namespace Unity_Studio
|
||||
if (fileGen >= 14)
|
||||
{
|
||||
//this looks like a list of assets that need to be preloaded in memory before anytihng else
|
||||
int someCount = a_Stream.ReadInt32();
|
||||
int someCount = assetsFileReader.ReadInt32();
|
||||
for (int i = 0; i < someCount; i++)
|
||||
{
|
||||
int num1 = a_Stream.ReadInt32();
|
||||
a_Stream.AlignStream(4);
|
||||
long m_PathID = a_Stream.ReadInt64();
|
||||
int num1 = assetsFileReader.ReadInt32();
|
||||
assetsFileReader.AlignStream(4);
|
||||
long m_PathID = assetsFileReader.ReadInt64();
|
||||
}
|
||||
}
|
||||
|
||||
int sharedFileCount = a_Stream.ReadInt32();
|
||||
int sharedFileCount = assetsFileReader.ReadInt32();
|
||||
for (int i = 0; i < sharedFileCount; i++)
|
||||
{
|
||||
UnityShared shared = new UnityShared();
|
||||
shared.aName = a_Stream.ReadStringToNull();
|
||||
a_Stream.Position += 20;
|
||||
string sharedFileName = a_Stream.ReadStringToNull(); //relative path
|
||||
shared.fileName = sharedFileName.Replace("/", "\\");
|
||||
var shared = new SharedAssets();
|
||||
shared.aName = assetsFileReader.ReadStringToNull();
|
||||
assetsFileReader.Position += 20;
|
||||
var sharedFilePath = assetsFileReader.ReadStringToNull(); //relative path
|
||||
shared.fileName = Path.GetFileName(sharedFilePath);
|
||||
sharedAssetsList.Add(shared);
|
||||
}
|
||||
valid = true;
|
||||
@@ -408,16 +363,16 @@ namespace Unity_Studio
|
||||
|
||||
private void readBase(List<ClassMember> cb, int level)
|
||||
{
|
||||
string varType = a_Stream.ReadStringToNull();
|
||||
string varName = a_Stream.ReadStringToNull();
|
||||
int size = a_Stream.ReadInt32();
|
||||
int index = a_Stream.ReadInt32();
|
||||
int isArray = a_Stream.ReadInt32();
|
||||
int num0 = a_Stream.ReadInt32();
|
||||
int flag = a_Stream.ReadInt32();
|
||||
int childrenCount = a_Stream.ReadInt32();
|
||||
string varType = assetsFileReader.ReadStringToNull();
|
||||
string varName = assetsFileReader.ReadStringToNull();
|
||||
int size = assetsFileReader.ReadInt32();
|
||||
int index = assetsFileReader.ReadInt32();
|
||||
int isArray = assetsFileReader.ReadInt32();
|
||||
int num0 = assetsFileReader.ReadInt32();
|
||||
int flag = assetsFileReader.ReadInt32();
|
||||
int childrenCount = assetsFileReader.ReadInt32();
|
||||
|
||||
cb.Add(new ClassMember()
|
||||
cb.Add(new ClassMember
|
||||
{
|
||||
Level = level - 1,
|
||||
Type = varType,
|
||||
@@ -430,12 +385,12 @@ namespace Unity_Studio
|
||||
|
||||
private void readBase5()
|
||||
{
|
||||
int classID = a_Stream.ReadInt32();
|
||||
int classID = assetsFileReader.ReadInt32();
|
||||
if (fileGen > 15)//5.5.0 and up
|
||||
{
|
||||
a_Stream.ReadByte();
|
||||
assetsFileReader.ReadByte();
|
||||
int type1;
|
||||
if ((type1 = a_Stream.ReadInt16()) >= 0)
|
||||
if ((type1 = assetsFileReader.ReadInt16()) >= 0)
|
||||
{
|
||||
type1 = -1 - type1;
|
||||
}
|
||||
@@ -446,82 +401,85 @@ namespace Unity_Studio
|
||||
classIDs.Add(new[] { type1, classID });
|
||||
if (classID == 114)
|
||||
{
|
||||
a_Stream.Position += 16;
|
||||
assetsFileReader.Position += 16;
|
||||
}
|
||||
classID = type1;
|
||||
}
|
||||
else if (classID < 0)
|
||||
{
|
||||
a_Stream.Position += 16;
|
||||
assetsFileReader.Position += 16;
|
||||
}
|
||||
a_Stream.Position += 16;
|
||||
assetsFileReader.Position += 16;
|
||||
|
||||
if (baseDefinitions)
|
||||
{
|
||||
int varCount = a_Stream.ReadInt32();
|
||||
int stringSize = a_Stream.ReadInt32();
|
||||
int varCount = assetsFileReader.ReadInt32();
|
||||
int stringSize = assetsFileReader.ReadInt32();
|
||||
|
||||
a_Stream.Position += varCount * 24;
|
||||
var stringReader = new EndianBinaryReader(new MemoryStream(a_Stream.ReadBytes(stringSize)));
|
||||
string className = "";
|
||||
var classVar = new List<ClassMember>();
|
||||
//build Class Structures
|
||||
a_Stream.Position -= varCount * 24 + stringSize;
|
||||
for (int i = 0; i < varCount; i++)
|
||||
assetsFileReader.Position += varCount * 24;
|
||||
using (var stringReader = new BinaryReader(new MemoryStream(assetsFileReader.ReadBytes(stringSize))))
|
||||
{
|
||||
ushort num0 = a_Stream.ReadUInt16();
|
||||
byte level = a_Stream.ReadByte();
|
||||
bool isArray = a_Stream.ReadBoolean();
|
||||
string className = "";
|
||||
var classVar = new List<ClassMember>();
|
||||
//build Class Structures
|
||||
assetsFileReader.Position -= varCount * 24 + stringSize;
|
||||
for (int i = 0; i < varCount; i++)
|
||||
{
|
||||
ushort num0 = assetsFileReader.ReadUInt16();
|
||||
byte level = assetsFileReader.ReadByte();
|
||||
bool isArray = assetsFileReader.ReadBoolean();
|
||||
|
||||
ushort varTypeIndex = a_Stream.ReadUInt16();
|
||||
ushort test = a_Stream.ReadUInt16();
|
||||
string varTypeStr;
|
||||
if (test == 0) //varType is an offset in the string block
|
||||
{
|
||||
stringReader.Position = varTypeIndex;
|
||||
varTypeStr = stringReader.ReadStringToNull();
|
||||
}
|
||||
else //varType is an index in an internal strig array
|
||||
{
|
||||
varTypeStr = baseStrings.ContainsKey(varTypeIndex) ? baseStrings[varTypeIndex] : varTypeIndex.ToString();
|
||||
}
|
||||
|
||||
ushort varNameIndex = a_Stream.ReadUInt16();
|
||||
test = a_Stream.ReadUInt16();
|
||||
string varNameStr;
|
||||
if (test == 0)
|
||||
{
|
||||
stringReader.Position = varNameIndex;
|
||||
varNameStr = stringReader.ReadStringToNull();
|
||||
}
|
||||
else
|
||||
{
|
||||
varNameStr = baseStrings.ContainsKey(varNameIndex) ? baseStrings[varNameIndex] : varNameIndex.ToString();
|
||||
}
|
||||
|
||||
int size = a_Stream.ReadInt32();
|
||||
int index = a_Stream.ReadInt32();
|
||||
int flag = a_Stream.ReadInt32();
|
||||
|
||||
if (index == 0) { className = varTypeStr + " " + varNameStr; }
|
||||
else
|
||||
{
|
||||
classVar.Add(new ClassMember()
|
||||
ushort varTypeIndex = assetsFileReader.ReadUInt16();
|
||||
ushort test = assetsFileReader.ReadUInt16();
|
||||
string varTypeStr;
|
||||
if (test == 0) //varType is an offset in the string block
|
||||
{
|
||||
Level = level - 1,
|
||||
Type = varTypeStr,
|
||||
Name = varNameStr,
|
||||
Size = size,
|
||||
Flag = flag
|
||||
});
|
||||
}
|
||||
}
|
||||
stringReader.Dispose();
|
||||
a_Stream.Position += stringSize;
|
||||
stringReader.BaseStream.Position = varTypeIndex;
|
||||
varTypeStr = stringReader.ReadStringToNull();
|
||||
}
|
||||
else //varType is an index in an internal strig array
|
||||
{
|
||||
varTypeStr = baseStrings.ContainsKey(varTypeIndex) ? baseStrings[varTypeIndex] : varTypeIndex.ToString();
|
||||
}
|
||||
|
||||
var aClass = new ClassStruct() { ID = classID, Text = className, members = classVar };
|
||||
aClass.SubItems.Add(classID.ToString());
|
||||
ClassStructures[classID] = aClass;
|
||||
ushort varNameIndex = assetsFileReader.ReadUInt16();
|
||||
test = assetsFileReader.ReadUInt16();
|
||||
string varNameStr;
|
||||
if (test == 0)
|
||||
{
|
||||
stringReader.BaseStream.Position = varNameIndex;
|
||||
varNameStr = stringReader.ReadStringToNull();
|
||||
}
|
||||
else
|
||||
{
|
||||
varNameStr = baseStrings.ContainsKey(varNameIndex) ? baseStrings[varNameIndex] : varNameIndex.ToString();
|
||||
}
|
||||
|
||||
int size = assetsFileReader.ReadInt32();
|
||||
int index = assetsFileReader.ReadInt32();
|
||||
int flag = assetsFileReader.ReadInt32();
|
||||
|
||||
if (index == 0)
|
||||
{
|
||||
className = varTypeStr + " " + varNameStr;
|
||||
}
|
||||
else
|
||||
{
|
||||
classVar.Add(new ClassMember
|
||||
{
|
||||
Level = level - 1,
|
||||
Type = varTypeStr,
|
||||
Name = varNameStr,
|
||||
Size = size,
|
||||
Flag = flag
|
||||
});
|
||||
}
|
||||
}
|
||||
assetsFileReader.Position += stringSize;
|
||||
var aClass = new ClassStruct { ID = classID, Text = className, members = classVar };
|
||||
aClass.SubItems.Add(classID.ToString());
|
||||
ClassStructures[classID] = aClass;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
128
AssetStudio/StudioClasses/BinaryReaderExtensions.cs
Normal file
128
AssetStudio/StudioClasses/BinaryReaderExtensions.cs
Normal file
@@ -0,0 +1,128 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using SharpDX;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public static class BinaryReaderExtensions
|
||||
{
|
||||
public static void AlignStream(this BinaryReader reader, int alignment)
|
||||
{
|
||||
var pos = reader.BaseStream.Position;
|
||||
var mod = pos % alignment;
|
||||
if (mod != 0)
|
||||
{
|
||||
reader.BaseStream.Position += alignment - mod;
|
||||
}
|
||||
}
|
||||
|
||||
public static string ReadAlignedString(this BinaryReader reader)
|
||||
{
|
||||
return ReadAlignedString(reader, reader.ReadInt32());
|
||||
}
|
||||
|
||||
public static string ReadAlignedString(this BinaryReader reader, int length)
|
||||
{
|
||||
if (length > 0 && length < (reader.BaseStream.Length - reader.BaseStream.Position))
|
||||
{
|
||||
var stringData = reader.ReadBytes(length);
|
||||
var result = Encoding.UTF8.GetString(stringData);
|
||||
reader.AlignStream(4);
|
||||
return result;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static string ReadStringToNull(this BinaryReader reader)
|
||||
{
|
||||
var bytes = new List<byte>();
|
||||
byte b;
|
||||
while (reader.BaseStream.Position != reader.BaseStream.Length && (b = reader.ReadByte()) != 0)
|
||||
bytes.Add(b);
|
||||
return Encoding.UTF8.GetString(bytes.ToArray());
|
||||
}
|
||||
|
||||
public static Quaternion ReadQuaternion(this BinaryReader reader)
|
||||
{
|
||||
var q = new Quaternion
|
||||
{
|
||||
X = reader.ReadSingle(),
|
||||
Y = reader.ReadSingle(),
|
||||
Z = reader.ReadSingle(),
|
||||
W = reader.ReadSingle()
|
||||
};
|
||||
return q;
|
||||
}
|
||||
|
||||
public static Vector2 ReadVector2(this BinaryReader reader)
|
||||
{
|
||||
Vector2 v = new Vector2
|
||||
{
|
||||
X = reader.ReadSingle(),
|
||||
Y = reader.ReadSingle()
|
||||
};
|
||||
return v;
|
||||
}
|
||||
|
||||
public static Vector3 ReadVector3(this BinaryReader reader)
|
||||
{
|
||||
var v = new Vector3
|
||||
{
|
||||
X = reader.ReadSingle(),
|
||||
Y = reader.ReadSingle(),
|
||||
Z = reader.ReadSingle()
|
||||
};
|
||||
return v;
|
||||
}
|
||||
|
||||
public static Vector4 ReadVector4(this BinaryReader reader)
|
||||
{
|
||||
var v = new Vector4
|
||||
{
|
||||
X = reader.ReadSingle(),
|
||||
Y = reader.ReadSingle(),
|
||||
Z = reader.ReadSingle(),
|
||||
W = reader.ReadSingle()
|
||||
};
|
||||
return v;
|
||||
}
|
||||
|
||||
private static T[] ReadArray<T>(Func<T> del, int length)
|
||||
{
|
||||
var array = new T[length];
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
array[i] = del();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public static int[] ReadInt32Array(this BinaryReader reader, int length)
|
||||
{
|
||||
return ReadArray(reader.ReadInt32, length);
|
||||
}
|
||||
|
||||
public static uint[] ReadUInt32Array(this BinaryReader reader, int length)
|
||||
{
|
||||
return ReadArray(reader.ReadUInt32, length);
|
||||
}
|
||||
|
||||
public static float[] ReadSingleArray(this BinaryReader reader, int length)
|
||||
{
|
||||
return ReadArray(reader.ReadSingle, length);
|
||||
}
|
||||
|
||||
public static Vector2[] ReadVector2Array(this BinaryReader reader, int length)
|
||||
{
|
||||
return ReadArray(reader.ReadVector2, length);
|
||||
}
|
||||
|
||||
public static Vector4[] ReadVector4Array(this BinaryReader reader, int length)
|
||||
{
|
||||
return ReadArray(reader.ReadVector4, length);
|
||||
}
|
||||
}
|
||||
}
|
||||
24
AssetStudio/StudioClasses/BinaryWriterExtensions.cs
Normal file
24
AssetStudio/StudioClasses/BinaryWriterExtensions.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public static class BinaryWriterExtensions
|
||||
{
|
||||
private static void WriteArray<T>(Action<T> del, T[] array)
|
||||
{
|
||||
foreach (var item in array)
|
||||
{
|
||||
del(item);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Write(this BinaryWriter writer, uint[] array)
|
||||
{
|
||||
WriteArray(writer.Write, array);
|
||||
}
|
||||
}
|
||||
}
|
||||
46
AssetStudio/StudioClasses/BuildTarget.cs
Normal file
46
AssetStudio/StudioClasses/BuildTarget.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public enum BuildTarget
|
||||
{
|
||||
DashboardWidget = 1,
|
||||
StandaloneOSX = 2,
|
||||
StandaloneOSXPPC = 3,
|
||||
StandaloneOSXIntel = 4,
|
||||
StandaloneWindows,
|
||||
WebPlayer,
|
||||
WebPlayerStreamed,
|
||||
Wii = 8,
|
||||
iOS = 9,
|
||||
PS3,
|
||||
XBOX360,
|
||||
Android = 13,
|
||||
StandaloneGLESEmu = 14,
|
||||
NaCl = 16,
|
||||
StandaloneLinux = 17,
|
||||
FlashPlayer = 18,
|
||||
StandaloneWindows64 = 19,
|
||||
WebGL,
|
||||
WSAPlayer,
|
||||
StandaloneLinux64 = 24,
|
||||
StandaloneLinuxUniversal,
|
||||
WP8Player,
|
||||
StandaloneOSXIntel64,
|
||||
BlackBerry,
|
||||
Tizen,
|
||||
PSP2,
|
||||
PS4,
|
||||
PSM,
|
||||
XboxOne,
|
||||
SamsungTV,
|
||||
N3DS,
|
||||
WiiU,
|
||||
tvOS,
|
||||
Switch,
|
||||
NoTarget = -2
|
||||
}
|
||||
}
|
||||
@@ -3,163 +3,127 @@ using System.IO;
|
||||
using Lz4;
|
||||
using SevenZip.Compression.LZMA;
|
||||
|
||||
namespace Unity_Studio
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class MemoryFile
|
||||
{
|
||||
public string fileName;
|
||||
public MemoryStream stream;
|
||||
}
|
||||
|
||||
public class BundleFile
|
||||
{
|
||||
public int format;
|
||||
public string versionPlayer;
|
||||
public string versionEngine;
|
||||
public List<MemoryAssetsFile> MemoryAssetsFileList = new List<MemoryAssetsFile>();
|
||||
public List<MemoryFile> fileList = new List<MemoryFile>();
|
||||
|
||||
public class MemoryAssetsFile
|
||||
public BundleFile(EndianBinaryReader bundleReader)
|
||||
{
|
||||
public string fileName;
|
||||
public MemoryStream memStream;
|
||||
}
|
||||
|
||||
public BundleFile(string fileName)
|
||||
{
|
||||
if (Path.GetExtension(fileName) == ".lz4")
|
||||
{
|
||||
byte[] filebuffer;
|
||||
|
||||
using (BinaryReader lz4Stream = new BinaryReader(File.OpenRead(fileName)))
|
||||
{
|
||||
int version = lz4Stream.ReadInt32();
|
||||
int uncompressedSize = lz4Stream.ReadInt32();
|
||||
int compressedSize = lz4Stream.ReadInt32();
|
||||
int something = lz4Stream.ReadInt32(); //1
|
||||
|
||||
var lz4buffer = lz4Stream.ReadBytes(compressedSize);
|
||||
using (var inputStream = new MemoryStream(lz4buffer))
|
||||
{
|
||||
var decoder = new Lz4DecoderStream(inputStream);
|
||||
filebuffer = new byte[uncompressedSize];
|
||||
decoder.Read(filebuffer, 0, uncompressedSize);
|
||||
decoder.Dispose();
|
||||
}
|
||||
}
|
||||
using (var b_Stream = new EndianBinaryReader(new MemoryStream(filebuffer)))
|
||||
{
|
||||
readBundle(b_Stream);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
using (var b_Stream = new EndianBinaryReader(File.OpenRead(fileName)))
|
||||
{
|
||||
readBundle(b_Stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void readBundle(EndianBinaryReader b_Stream)
|
||||
{
|
||||
var signature = b_Stream.ReadStringToNull();
|
||||
var signature = bundleReader.ReadStringToNull();
|
||||
switch (signature)
|
||||
{
|
||||
case "UnityWeb":
|
||||
case "UnityRaw":
|
||||
case "\xFA\xFA\xFA\xFA\xFA\xFA\xFA\xFA":
|
||||
{
|
||||
format = b_Stream.ReadInt32();
|
||||
versionPlayer = b_Stream.ReadStringToNull();
|
||||
versionEngine = b_Stream.ReadStringToNull();
|
||||
format = bundleReader.ReadInt32();
|
||||
versionPlayer = bundleReader.ReadStringToNull();
|
||||
versionEngine = bundleReader.ReadStringToNull();
|
||||
if (format < 6)
|
||||
{
|
||||
int bundleSize = b_Stream.ReadInt32();
|
||||
int bundleSize = bundleReader.ReadInt32();
|
||||
}
|
||||
else if (format == 6)
|
||||
{
|
||||
ReadFormat6(b_Stream, true);
|
||||
ReadFormat6(bundleReader, true);
|
||||
return;
|
||||
}
|
||||
short dummy2 = b_Stream.ReadInt16();
|
||||
int offset = b_Stream.ReadInt16();
|
||||
int dummy3 = b_Stream.ReadInt32();
|
||||
int lzmaChunks = b_Stream.ReadInt32();
|
||||
short dummy2 = bundleReader.ReadInt16();
|
||||
int offset = bundleReader.ReadInt16();
|
||||
int dummy3 = bundleReader.ReadInt32();
|
||||
int lzmaChunks = bundleReader.ReadInt32();
|
||||
|
||||
int lzmaSize = 0;
|
||||
long streamSize = 0;
|
||||
|
||||
for (int i = 0; i < lzmaChunks; i++)
|
||||
{
|
||||
lzmaSize = b_Stream.ReadInt32();
|
||||
streamSize = b_Stream.ReadInt32();
|
||||
lzmaSize = bundleReader.ReadInt32();
|
||||
streamSize = bundleReader.ReadInt32();
|
||||
}
|
||||
|
||||
b_Stream.Position = offset;
|
||||
bundleReader.Position = offset;
|
||||
switch (signature)
|
||||
{
|
||||
case "\xFA\xFA\xFA\xFA\xFA\xFA\xFA\xFA": //.bytes
|
||||
case "UnityWeb":
|
||||
{
|
||||
var lzmaBuffer = b_Stream.ReadBytes(lzmaSize);
|
||||
var lzmaBuffer = bundleReader.ReadBytes(lzmaSize);
|
||||
using (var lzmaStream = new EndianBinaryReader(SevenZipHelper.StreamDecompress(new MemoryStream(lzmaBuffer))))
|
||||
{
|
||||
getFiles(lzmaStream, 0);
|
||||
GetAssetsFiles(lzmaStream, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "UnityRaw":
|
||||
{
|
||||
getFiles(b_Stream, offset);
|
||||
GetAssetsFiles(bundleReader, offset);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "UnityFS":
|
||||
format = b_Stream.ReadInt32();
|
||||
versionPlayer = b_Stream.ReadStringToNull();
|
||||
versionEngine = b_Stream.ReadStringToNull();
|
||||
format = bundleReader.ReadInt32();
|
||||
versionPlayer = bundleReader.ReadStringToNull();
|
||||
versionEngine = bundleReader.ReadStringToNull();
|
||||
if (format == 6)
|
||||
{
|
||||
ReadFormat6(b_Stream);
|
||||
ReadFormat6(bundleReader);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void getFiles(EndianBinaryReader f_Stream, int offset)
|
||||
private void GetAssetsFiles(EndianBinaryReader reader, int offset)
|
||||
{
|
||||
int fileCount = f_Stream.ReadInt32();
|
||||
int fileCount = reader.ReadInt32();
|
||||
for (int i = 0; i < fileCount; i++)
|
||||
{
|
||||
var memFile = new MemoryAssetsFile();
|
||||
memFile.fileName = f_Stream.ReadStringToNull();
|
||||
int fileOffset = f_Stream.ReadInt32();
|
||||
var file = new MemoryFile();
|
||||
file.fileName = reader.ReadStringToNull();
|
||||
int fileOffset = reader.ReadInt32();
|
||||
fileOffset += offset;
|
||||
int fileSize = f_Stream.ReadInt32();
|
||||
long nextFile = f_Stream.Position;
|
||||
f_Stream.Position = fileOffset;
|
||||
var buffer = f_Stream.ReadBytes(fileSize);
|
||||
memFile.memStream = new MemoryStream(buffer);
|
||||
MemoryAssetsFileList.Add(memFile);
|
||||
f_Stream.Position = nextFile;
|
||||
int fileSize = reader.ReadInt32();
|
||||
long nextFile = reader.Position;
|
||||
reader.Position = fileOffset;
|
||||
var buffer = reader.ReadBytes(fileSize);
|
||||
file.stream = new MemoryStream(buffer);
|
||||
fileList.Add(file);
|
||||
reader.Position = nextFile;
|
||||
}
|
||||
}
|
||||
|
||||
private void ReadFormat6(EndianBinaryReader b_Stream, bool padding = false)
|
||||
private void ReadFormat6(EndianBinaryReader bundleReader, bool padding = false)
|
||||
{
|
||||
var bundleSize = b_Stream.ReadInt64();
|
||||
int compressedSize = b_Stream.ReadInt32();
|
||||
int uncompressedSize = b_Stream.ReadInt32();
|
||||
int flag = b_Stream.ReadInt32();
|
||||
var bundleSize = bundleReader.ReadInt64();
|
||||
int compressedSize = bundleReader.ReadInt32();
|
||||
int uncompressedSize = bundleReader.ReadInt32();
|
||||
int flag = bundleReader.ReadInt32();
|
||||
if (padding)
|
||||
b_Stream.ReadByte();
|
||||
bundleReader.ReadByte();
|
||||
byte[] blocksInfoBytes;
|
||||
if ((flag & 0x80) != 0)//at end of file
|
||||
{
|
||||
var position = b_Stream.Position;
|
||||
b_Stream.Position = b_Stream.BaseStream.Length - compressedSize;
|
||||
blocksInfoBytes = b_Stream.ReadBytes(compressedSize);
|
||||
b_Stream.Position = position;
|
||||
var position = bundleReader.Position;
|
||||
bundleReader.Position = bundleReader.BaseStream.Length - compressedSize;
|
||||
blocksInfoBytes = bundleReader.ReadBytes(compressedSize);
|
||||
bundleReader.Position = position;
|
||||
}
|
||||
else
|
||||
{
|
||||
blocksInfoBytes = b_Stream.ReadBytes(compressedSize);
|
||||
blocksInfoBytes = bundleReader.ReadBytes(compressedSize);
|
||||
}
|
||||
MemoryStream blocksInfoStream;
|
||||
switch (flag & 0x3F)
|
||||
@@ -178,11 +142,9 @@ namespace Unity_Studio
|
||||
case 3://LZ4HC
|
||||
{
|
||||
byte[] uncompressedBytes = new byte[uncompressedSize];
|
||||
using (var mstream = new MemoryStream(blocksInfoBytes))
|
||||
using (var decoder = new Lz4DecoderStream(new MemoryStream(blocksInfoBytes)))
|
||||
{
|
||||
var decoder = new Lz4DecoderStream(mstream);
|
||||
decoder.Read(uncompressedBytes, 0, uncompressedSize);
|
||||
decoder.Dispose();
|
||||
}
|
||||
blocksInfoStream = new MemoryStream(uncompressedBytes);
|
||||
break;
|
||||
@@ -199,7 +161,7 @@ namespace Unity_Studio
|
||||
uncompressedSize = blocksInfo.ReadInt32();
|
||||
compressedSize = blocksInfo.ReadInt32();
|
||||
flag = blocksInfo.ReadInt16();
|
||||
var compressedBytes = b_Stream.ReadBytes(compressedSize);
|
||||
var compressedBytes = bundleReader.ReadBytes(compressedSize);
|
||||
switch (flag & 0x3F)
|
||||
{
|
||||
default://None
|
||||
@@ -223,11 +185,9 @@ namespace Unity_Studio
|
||||
case 3://LZ4HC
|
||||
{
|
||||
var uncompressedBytes = new byte[uncompressedSize];
|
||||
using (var mstream = new MemoryStream(compressedBytes))
|
||||
using (var decoder = new Lz4DecoderStream(new MemoryStream(compressedBytes)))
|
||||
{
|
||||
var decoder = new Lz4DecoderStream(mstream);
|
||||
decoder.Read(uncompressedBytes, 0, uncompressedSize);
|
||||
decoder.Dispose();
|
||||
}
|
||||
assetsDataStream.Write(uncompressedBytes, 0, uncompressedSize);
|
||||
break;
|
||||
@@ -235,20 +195,20 @@ namespace Unity_Studio
|
||||
//case 4:LZHAM?
|
||||
}
|
||||
}
|
||||
using (var assetsData = new EndianBinaryReader(assetsDataStream))
|
||||
using (var assetsDataReader = new EndianBinaryReader(assetsDataStream))
|
||||
{
|
||||
var entryinfo_count = blocksInfo.ReadInt32();
|
||||
for (int i = 0; i < entryinfo_count; i++)
|
||||
{
|
||||
var memFile = new MemoryAssetsFile();
|
||||
var file = new MemoryFile();
|
||||
var entryinfo_offset = blocksInfo.ReadInt64();
|
||||
var entryinfo_size = blocksInfo.ReadInt64();
|
||||
var unknown = blocksInfo.ReadInt32();
|
||||
memFile.fileName = blocksInfo.ReadStringToNull();
|
||||
assetsData.Position = entryinfo_offset;
|
||||
var buffer = assetsData.ReadBytes((int)entryinfo_size);
|
||||
memFile.memStream = new MemoryStream(buffer);
|
||||
MemoryAssetsFileList.Add(memFile);
|
||||
flag = blocksInfo.ReadInt32();
|
||||
file.fileName = Path.GetFileName(blocksInfo.ReadStringToNull());
|
||||
assetsDataReader.Position = entryinfo_offset;
|
||||
var buffer = assetsDataReader.ReadBytes((int)entryinfo_size);
|
||||
file.stream = new MemoryStream(buffer);
|
||||
fileList.Add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
272
AssetStudio/StudioClasses/ClassIDReference.cs
Normal file
272
AssetStudio/StudioClasses/ClassIDReference.cs
Normal file
@@ -0,0 +1,272 @@
|
||||
namespace AssetStudio
|
||||
{
|
||||
public enum ClassIDReference
|
||||
{
|
||||
UnknownType = -1,
|
||||
GameObject = 1,
|
||||
Component = 2,
|
||||
LevelGameManager = 3,
|
||||
Transform = 4,
|
||||
TimeManager = 5,
|
||||
GlobalGameManager = 6,
|
||||
Behaviour = 8,
|
||||
GameManager = 9,
|
||||
AudioManager = 11,
|
||||
ParticleAnimator = 12,
|
||||
InputManager = 13,
|
||||
EllipsoidParticleEmitter = 15,
|
||||
Pipeline = 17,
|
||||
EditorExtension = 18,
|
||||
Physics2DSettings = 19,
|
||||
Camera = 20,
|
||||
Material = 21,
|
||||
MeshRenderer = 23,
|
||||
Renderer = 25,
|
||||
ParticleRenderer = 26,
|
||||
Texture = 27,
|
||||
Texture2D = 28,
|
||||
SceneSettings = 29,
|
||||
GraphicsSettings = 30,
|
||||
MeshFilter = 33,
|
||||
OcclusionPortal = 41,
|
||||
Mesh = 43,
|
||||
Skybox = 45,
|
||||
QualitySettings = 47,
|
||||
Shader = 48,
|
||||
TextAsset = 49,
|
||||
Rigidbody2D = 50,
|
||||
Physics2DManager = 51,
|
||||
Collider2D = 53,
|
||||
Rigidbody = 54,
|
||||
PhysicsManager = 55,
|
||||
Collider = 56,
|
||||
Joint = 57,
|
||||
CircleCollider2D = 58,
|
||||
HingeJoint = 59,
|
||||
PolygonCollider2D = 60,
|
||||
BoxCollider2D = 61,
|
||||
PhysicsMaterial2D = 62,
|
||||
MeshCollider = 64,
|
||||
BoxCollider = 65,
|
||||
SpriteCollider2D = 66,
|
||||
EdgeCollider2D = 68,
|
||||
CapsuleCollider2D = 70,
|
||||
ComputeShader = 72,
|
||||
AnimationClip = 74,
|
||||
ConstantForce = 75,
|
||||
WorldParticleCollider = 76,
|
||||
TagManager = 78,
|
||||
AudioListener = 81,
|
||||
AudioSource = 82,
|
||||
AudioClip = 83,
|
||||
RenderTexture = 84,
|
||||
CustomRenderTexture = 86,
|
||||
MeshParticleEmitter = 87,
|
||||
ParticleEmitter = 88,
|
||||
Cubemap = 89,
|
||||
Avatar = 90,
|
||||
AnimatorController = 91,
|
||||
GUILayer = 92,
|
||||
RuntimeAnimatorController = 93,
|
||||
ScriptMapper = 94,
|
||||
Animator = 95,
|
||||
TrailRenderer = 96,
|
||||
DelayedCallManager = 98,
|
||||
TextMesh = 102,
|
||||
RenderSettings = 104,
|
||||
Light = 108,
|
||||
CGProgram = 109,
|
||||
BaseAnimationTrack = 110,
|
||||
Animation = 111,
|
||||
MonoBehaviour = 114,
|
||||
MonoScript = 115,
|
||||
MonoManager = 116,
|
||||
Texture3D = 117,
|
||||
NewAnimationTrack = 118,
|
||||
Projector = 119,
|
||||
LineRenderer = 120,
|
||||
Flare = 121,
|
||||
Halo = 122,
|
||||
LensFlare = 123,
|
||||
FlareLayer = 124,
|
||||
HaloLayer = 125,
|
||||
NavMeshAreas = 126,
|
||||
HaloManager = 127,
|
||||
Font = 128,
|
||||
PlayerSettings = 129,
|
||||
NamedObject = 130,
|
||||
GUITexture = 131,
|
||||
GUIText = 132,
|
||||
GUIElement = 133,
|
||||
PhysicMaterial = 134,
|
||||
SphereCollider = 135,
|
||||
CapsuleCollider = 136,
|
||||
SkinnedMeshRenderer = 137,
|
||||
FixedJoint = 138,
|
||||
RaycastCollider = 140,
|
||||
BuildSettings = 141,
|
||||
AssetBundle = 142,
|
||||
CharacterController = 143,
|
||||
CharacterJoint = 144,
|
||||
SpringJoint = 145,
|
||||
WheelCollider = 146,
|
||||
ResourceManager = 147,
|
||||
NetworkView = 148,
|
||||
NetworkManager = 149,
|
||||
PreloadData = 150,
|
||||
MovieTexture = 152,
|
||||
ConfigurableJoint = 153,
|
||||
TerrainCollider = 154,
|
||||
MasterServerInterface = 155,
|
||||
TerrainData = 156,
|
||||
LightmapSettings = 157,
|
||||
WebCamTexture = 158,
|
||||
EditorSettings = 159,
|
||||
InteractiveCloth = 160,
|
||||
ClothRenderer = 161,
|
||||
EditorUserSettings = 162,
|
||||
SkinnedCloth = 163,
|
||||
AudioReverbFilter = 164,
|
||||
AudioHighPassFilter = 165,
|
||||
AudioChorusFilter = 166,
|
||||
AudioReverbZone = 167,
|
||||
AudioEchoFilter = 168,
|
||||
AudioLowPassFilter = 169,
|
||||
AudioDistortionFilter = 170,
|
||||
SparseTexture = 171,
|
||||
AudioBehaviour = 180,
|
||||
AudioFilter = 181,
|
||||
WindZone = 182,
|
||||
Cloth = 183,
|
||||
SubstanceArchive = 184,
|
||||
ProceduralMaterial = 185,
|
||||
ProceduralTexture = 186,
|
||||
Texture2DArray = 187,
|
||||
CubemapArray = 188,
|
||||
OffMeshLink = 191,
|
||||
OcclusionArea = 192,
|
||||
Tree = 193,
|
||||
NavMeshObsolete = 194,
|
||||
NavMeshAgent = 195,
|
||||
NavMeshSettings = 196,
|
||||
LightProbesLegacy = 197,
|
||||
ParticleSystem = 198,
|
||||
ParticleSystemRenderer = 199,
|
||||
ShaderVariantCollection = 200,
|
||||
LODGroup = 205,
|
||||
BlendTree = 206,
|
||||
Motion = 207,
|
||||
NavMeshObstacle = 208,
|
||||
TerrainInstance = 210,
|
||||
SpriteRenderer = 212,
|
||||
Sprite = 213,
|
||||
CachedSpriteAtlas = 214,
|
||||
ReflectionProbe = 215,
|
||||
ReflectionProbes = 216,
|
||||
Terrain = 218,
|
||||
LightProbeGroup = 220,
|
||||
AnimatorOverrideController = 221,
|
||||
CanvasRenderer = 222,
|
||||
Canvas = 223,
|
||||
RectTransform = 224,
|
||||
CanvasGroup = 225,
|
||||
BillboardAsset = 226,
|
||||
BillboardRenderer = 227,
|
||||
SpeedTreeWindAsset = 228,
|
||||
AnchoredJoint2D = 229,
|
||||
Joint2D = 230,
|
||||
SpringJoint2D = 231,
|
||||
DistanceJoint2D = 232,
|
||||
HingeJoint2D = 233,
|
||||
SliderJoint2D = 234,
|
||||
WheelJoint2D = 235,
|
||||
ClusterInputManager = 236,
|
||||
BaseVideoTexture = 237,
|
||||
NavMeshData = 238,
|
||||
AudioMixer = 240,
|
||||
AudioMixerController = 241,
|
||||
AudioMixerGroupController = 243,
|
||||
AudioMixerEffectController = 244,
|
||||
AudioMixerSnapshotController = 245,
|
||||
PhysicsUpdateBehaviour2D = 246,
|
||||
ConstantForce2D = 247,
|
||||
Effector2D = 248,
|
||||
AreaEffector2D = 249,
|
||||
PointEffector2D = 250,
|
||||
PlatformEffector2D = 251,
|
||||
SurfaceEffector2D = 252,
|
||||
BuoyancyEffector2D = 253,
|
||||
RelativeJoint2D = 254,
|
||||
FixedJoint2D = 255,
|
||||
FrictionJoint2D = 256,
|
||||
TargetJoint2D = 257,
|
||||
LightProbes = 258,
|
||||
LightProbeProxyVolume = 259,
|
||||
SampleClip = 271,
|
||||
AudioMixerSnapshot = 272,
|
||||
AudioMixerGroup = 273,
|
||||
NScreenBridge = 280,
|
||||
AssetBundleManifest = 290,
|
||||
UnityAdsManager = 292,
|
||||
RuntimeInitializeOnLoadManager = 300,
|
||||
CloudWebServicesManager = 301,
|
||||
UnityAnalyticsManager = 303,
|
||||
CrashReportManager = 304,
|
||||
PerformanceReportingManager = 305,
|
||||
UnityConnectSettings = 310,
|
||||
AvatarMask = 319,
|
||||
VideoPlayer = 328,
|
||||
VideoClip = 329,
|
||||
OcclusionCullingData = 363,
|
||||
Prefab = 1001,
|
||||
EditorExtensionImpl = 1002,
|
||||
AssetImporter = 1003,
|
||||
AssetDatabase = 1004,
|
||||
Mesh3DSImporter = 1005,
|
||||
TextureImporter = 1006,
|
||||
ShaderImporter = 1007,
|
||||
ComputeShaderImporter = 1008,
|
||||
AudioImporter = 1020,
|
||||
HierarchyState = 1026,
|
||||
GUIDSerializer = 1027,
|
||||
AssetMetaData = 1028,
|
||||
DefaultAsset = 1029,
|
||||
DefaultImporter = 1030,
|
||||
TextScriptImporter = 1031,
|
||||
SceneAsset = 1032,
|
||||
NativeFormatImporter = 1034,
|
||||
MonoImporter = 1035,
|
||||
AssetServerCache = 1037,
|
||||
LibraryAssetImporter = 1038,
|
||||
ModelImporter = 1040,
|
||||
FBXImporter = 1041,
|
||||
TrueTypeFontImporter = 1042,
|
||||
MovieImporter = 1044,
|
||||
EditorBuildSettings = 1045,
|
||||
DDSImporter = 1046,
|
||||
InspectorExpandedState = 1048,
|
||||
AnnotationManager = 1049,
|
||||
PluginImporter = 1050,
|
||||
EditorUserBuildSettings = 1051,
|
||||
PVRImporter = 1052,
|
||||
ASTCImporter = 1053,
|
||||
KTXImporter = 1054,
|
||||
AnimatorStateTransition = 1101,
|
||||
AnimatorState = 1102,
|
||||
HumanTemplate = 1105,
|
||||
AnimatorStateMachine = 1107,
|
||||
PreviewAssetType = 1108,
|
||||
AnimatorTransition = 1109,
|
||||
SpeedTreeImporter = 1110,
|
||||
AnimatorTransitionBase = 1111,
|
||||
SubstanceImporter = 1112,
|
||||
LightmapParameters = 1113,
|
||||
LightmapSnapshot = 1120,
|
||||
SubDerived = 367388927,
|
||||
SiblingDerived = 334799969,
|
||||
SpriteAtlas = 687078895,
|
||||
Derived = 1091556383,
|
||||
LowerResBlitTexture = 1480428607,
|
||||
RenderPassAttachment = 1571458007
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user