From 7e67f354e4892eec700d69065cc37aea3412fa4d Mon Sep 17 00:00:00 2001 From: Perfare Date: Fri, 19 Jan 2018 10:25:37 +0800 Subject: [PATCH] fixed some bug --- Unity Studio.sln | 7 ++- .../Unity Studio Classes/UnityStudio.cs | 47 +++++++++++-------- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/Unity Studio.sln b/Unity Studio.sln index 33dddfe..a0fe4cb 100644 --- a/Unity Studio.sln +++ b/Unity Studio.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +# Visual Studio 15 +VisualStudioVersion = 15.0.27130.2024 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity Studio", "Unity Studio\Unity Studio.csproj", "{24551E2D-E9B6-4CD6-8F2A-D9F4A13E7853}" EndProject @@ -25,4 +25,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F5C476A6-2B3B-416F-8BD5-6FE454FF3972} + EndGlobalSection EndGlobal diff --git a/Unity Studio/Unity Studio Classes/UnityStudio.cs b/Unity Studio/Unity Studio Classes/UnityStudio.cs index 3b3a820..527a524 100644 --- a/Unity Studio/Unity Studio Classes/UnityStudio.cs +++ b/Unity Studio/Unity Studio Classes/UnityStudio.cs @@ -311,24 +311,24 @@ namespace Unity_Studio exportable = true; break; } - /*case 21: //Material - case 74: //AnimationClip - case 90: //Avatar - case 91: //AnimatorController - case 115: //MonoScript - case 687078895: //SpriteAtlas - { - if (asset.Offset + 4 > asset.sourceFile.a_Stream.BaseStream.Length) - break; - asset.sourceFile.a_Stream.Position = asset.Offset; - var len = asset.sourceFile.a_Stream.ReadInt32(); - if (len > 0 && len < asset.Size - 4) + /*case 21: //Material + case 74: //AnimationClip + case 90: //Avatar + case 91: //AnimatorController + case 115: //MonoScript + case 687078895: //SpriteAtlas { - var bytes = asset.sourceFile.a_Stream.ReadBytes(len); - asset.Text = Encoding.UTF8.GetString(bytes); - } - break; - }*/ + if (asset.Offset + 4 > asset.sourceFile.a_Stream.BaseStream.Length) + break; + asset.sourceFile.a_Stream.Position = asset.Offset; + var len = asset.sourceFile.a_Stream.ReadInt32(); + if (len > 0 && len < asset.Size - 4) + { + var bytes = asset.sourceFile.a_Stream.ReadBytes(len); + asset.Text = Encoding.UTF8.GetString(bytes); + } + break; + }*/ } if (!exportable && displayAll) { @@ -1797,12 +1797,21 @@ namespace Unity_Studio #endregion #region Face - for (int f = 0; f < m_Mesh.m_Indices.Count / 3; f++) + int sum = 0; + for (var i = 0; i < m_Mesh.m_SubMeshes.Count; i++) { - sb.AppendFormat("f {0}/{0}/{0} {1}/{1}/{1} {2}/{2}/{2}\r\n", m_Mesh.m_Indices[f * 3 + 2] + 1, m_Mesh.m_Indices[f * 3 + 1] + 1, m_Mesh.m_Indices[f * 3] + 1); + sb.AppendLine($"g {m_Mesh.m_Name}_{i}"); + int indexCount = (int)m_Mesh.m_SubMeshes[i].indexCount; + var end = sum + indexCount / 3; + for (int f = sum; f < end; f++) + { + sb.AppendFormat("f {0}/{0}/{0} {1}/{1}/{1} {2}/{2}/{2}\r\n", m_Mesh.m_Indices[f * 3 + 2] + 1, m_Mesh.m_Indices[f * 3 + 1] + 1, m_Mesh.m_Indices[f * 3] + 1); + } + sum = end; } #endregion + sb.Replace("NaN", "0"); File.WriteAllText(exportFullName, sb.ToString()); return true; }