diff --git a/Assets/UniGLTF/UniGLTF.asmdef b/Assets/UniGLTF/UniGLTF.asmdef index 6c2347308..d2f68d054 100644 --- a/Assets/UniGLTF/UniGLTF.asmdef +++ b/Assets/UniGLTF/UniGLTF.asmdef @@ -2,8 +2,7 @@ "name": "UniGLTF", "references": [ "UniUnlit", - "ShaderProperty.Runtime", - "MeshUtility" + "ShaderProperty.Runtime" ], "optionalUnityReferences": [], "includePlatforms": [], diff --git a/Assets/MeshUtility/Runtime/MeshExportInfo.cs b/Assets/UniGLTF/UniGLTF/Scripts/IO/MeshExportInfo.cs similarity index 88% rename from Assets/MeshUtility/Runtime/MeshExportInfo.cs rename to Assets/UniGLTF/UniGLTF/Scripts/IO/MeshExportInfo.cs index c11547f4e..de78ce315 100644 --- a/Assets/MeshUtility/Runtime/MeshExportInfo.cs +++ b/Assets/UniGLTF/UniGLTF/Scripts/IO/MeshExportInfo.cs @@ -1,16 +1,8 @@ using System; using UnityEngine; -namespace MeshUtility +namespace UniGLTF { - public struct MeshWithRenderer - { - public Mesh Mesh; - [Obsolete("Use Renderer")] - public Renderer Rendererer { get { return Renderer; } set { Renderer = value; } } - public Renderer Renderer; - } - [Serializable] public struct MeshExportInfo { @@ -74,14 +66,14 @@ namespace MeshUtility foreach (var m in materials) { var currentState = MaterialUseVertexColor(m) - ? MeshUtility.MeshExportInfo.VertexColorState.ExistsAndIsUsed - : MeshUtility.MeshExportInfo.VertexColorState.ExistsButNotUsed + ? MeshExportInfo.VertexColorState.ExistsAndIsUsed + : MeshExportInfo.VertexColorState.ExistsButNotUsed ; if (state.HasValue) { if (state.Value != currentState) { - state = MeshUtility.MeshExportInfo.VertexColorState.ExistsAndMixed; + state = MeshExportInfo.VertexColorState.ExistsAndMixed; break; } } diff --git a/Assets/MeshUtility/Runtime/MeshExportInfo.cs.meta b/Assets/UniGLTF/UniGLTF/Scripts/IO/MeshExportInfo.cs.meta similarity index 83% rename from Assets/MeshUtility/Runtime/MeshExportInfo.cs.meta rename to Assets/UniGLTF/UniGLTF/Scripts/IO/MeshExportInfo.cs.meta index 41e5c9e57..deaa43e4a 100644 --- a/Assets/MeshUtility/Runtime/MeshExportInfo.cs.meta +++ b/Assets/UniGLTF/UniGLTF/Scripts/IO/MeshExportInfo.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 2af6d95e4a0e06944b34d891d798b88b +guid: 14f3566dfa5223944bf4bdc936f58270 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/UniGLTF/UniGLTF/Scripts/IO/MeshExporter.cs b/Assets/UniGLTF/UniGLTF/Scripts/IO/MeshExporter.cs index 69d5584e2..f72809474 100644 --- a/Assets/UniGLTF/UniGLTF/Scripts/IO/MeshExporter.cs +++ b/Assets/UniGLTF/UniGLTF/Scripts/IO/MeshExporter.cs @@ -42,9 +42,9 @@ namespace UniGLTF var colorAccessorIndex = -1; - var vColorState = MeshUtility.MeshExportInfo.DetectVertexColor(mesh, materials); - if (vColorState == MeshUtility.MeshExportInfo.VertexColorState.ExistsAndIsUsed // VColor使っている - || vColorState == MeshUtility.MeshExportInfo.VertexColorState.ExistsAndMixed // VColorを使っているところと使っていないところが混在(とりあえずExportする) + var vColorState = MeshExportInfo.DetectVertexColor(mesh, materials); + if (vColorState == MeshExportInfo.VertexColorState.ExistsAndIsUsed // VColor使っている + || vColorState == MeshExportInfo.VertexColorState.ExistsAndMixed // VColorを使っているところと使っていないところが混在(とりあえずExportする) ) { // UniUnlit で Multiply 設定になっている @@ -251,8 +251,16 @@ namespace UniGLTF }; } + public struct MeshWithRenderer + { + public Mesh Mesh; + [Obsolete("Use Renderer")] + public Renderer Rendererer { get { return Renderer; } set { Renderer = value; } } + public Renderer Renderer; + } + public static IEnumerable<(Mesh, glTFMesh, Dictionary)> ExportMeshes(glTF gltf, int bufferIndex, - List unityMeshes, List unityMaterials, + List unityMeshes, List unityMaterials, MeshExportSettings settings) { for (int i = 0; i < unityMeshes.Count; ++i) diff --git a/Assets/UniGLTF/UniGLTF/Scripts/IO/gltfExporter.cs b/Assets/UniGLTF/UniGLTF/Scripts/IO/gltfExporter.cs index d17498d3b..30a535fd0 100644 --- a/Assets/UniGLTF/UniGLTF/Scripts/IO/gltfExporter.cs +++ b/Assets/UniGLTF/UniGLTF/Scripts/IO/gltfExporter.cs @@ -253,7 +253,7 @@ namespace UniGLTF #region Meshes var unityMeshes = Nodes - .Select(x => new MeshUtility.MeshWithRenderer + .Select(x => new MeshExporter.MeshWithRenderer { Mesh = x.GetSharedMesh(), Renderer = x.GetComponent(), diff --git a/Assets/UniGLTF/package.json b/Assets/UniGLTF/package.json index c4284165f..4e05ec04c 100644 --- a/Assets/UniGLTF/package.json +++ b/Assets/UniGLTF/package.json @@ -11,7 +11,6 @@ "name": "VRM Consortium" }, "dependencies": { - "com.vrmc.vrmshaders": "0.62.0", - "com.vrmc.meshutility": "0.62.0" + "com.vrmc.vrmshaders": "0.62.0" } } \ No newline at end of file diff --git a/Assets/MeshUtility/Editor/ExportDialog/Valildators/HumanoidValidator.cs b/Assets/VRM/UniVRM/Editor/Format/HumanoidValidator.cs similarity index 98% rename from Assets/MeshUtility/Editor/ExportDialog/Valildators/HumanoidValidator.cs rename to Assets/VRM/UniVRM/Editor/Format/HumanoidValidator.cs index cc89267b5..c67649d78 100644 --- a/Assets/MeshUtility/Editor/ExportDialog/Valildators/HumanoidValidator.cs +++ b/Assets/VRM/UniVRM/Editor/Format/HumanoidValidator.cs @@ -1,9 +1,10 @@ using System.Collections.Generic; using System.Linq; +using MeshUtility; using MeshUtility.M17N; using UnityEngine; -namespace MeshUtility.Validators +namespace VRM { public static class HumanoidValidator { @@ -73,7 +74,7 @@ namespace MeshUtility.Validators return Vector3.Cross(lr, Vector3.up); } - public static IReadOnlyList MeshInformations; + public static IReadOnlyList MeshInformations; public static bool EnableFreeze; public static IEnumerable Validate(GameObject ExportRoot) diff --git a/Assets/MeshUtility/Editor/ExportDialog/Valildators/HumanoidValidator.cs.meta b/Assets/VRM/UniVRM/Editor/Format/HumanoidValidator.cs.meta similarity index 83% rename from Assets/MeshUtility/Editor/ExportDialog/Valildators/HumanoidValidator.cs.meta rename to Assets/VRM/UniVRM/Editor/Format/HumanoidValidator.cs.meta index f50f4461a..6b9849e29 100644 --- a/Assets/MeshUtility/Editor/ExportDialog/Valildators/HumanoidValidator.cs.meta +++ b/Assets/VRM/UniVRM/Editor/Format/HumanoidValidator.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 9013f2150f3c6d943a6f6b6394f7a1ff +guid: d6dd0ca0faa486f4a8aa3bb895e2c697 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMEditorExporter.cs b/Assets/VRM/UniVRM/Editor/Format/VRMEditorExporter.cs index 03d86ae3f..96e236ab0 100644 --- a/Assets/VRM/UniVRM/Editor/Format/VRMEditorExporter.cs +++ b/Assets/VRM/UniVRM/Editor/Format/VRMEditorExporter.cs @@ -16,7 +16,7 @@ namespace VRM /// /// 出力先 /// エクスポート設定 - public static void Export(string path, GameObject exportRoot, VRMMetaObject meta, VRMExportSettings settings, IReadOnlyList info) + public static void Export(string path, GameObject exportRoot, VRMMetaObject meta, VRMExportSettings settings, IReadOnlyList info) { List destroy = new List(); try @@ -137,7 +137,7 @@ namespace VRM /// /// 作業が終わったらDestoryするべき一時オブジェクト static void Export(string path, GameObject exportRoot, VRMMetaObject meta, - VRMExportSettings settings, IReadOnlyList info, + VRMExportSettings settings, IReadOnlyList info, List destroy) { var target = exportRoot; diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMExportMeshes.cs b/Assets/VRM/UniVRM/Editor/Format/VRMExportMeshes.cs index 3225590e9..58e7e253d 100644 --- a/Assets/VRM/UniVRM/Editor/Format/VRMExportMeshes.cs +++ b/Assets/VRM/UniVRM/Editor/Format/VRMExportMeshes.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using MeshUtility; +using UniGLTF; using UnityEngine; namespace VRM @@ -56,14 +57,14 @@ namespace VRM return false; } - public List Meshes = new List(); + public List Meshes = new List(); public int ExpectedExportByteSize => Meshes.Where(x => x.IsRendererActive).Sum(x => x.ExportByteSize); List m_validations = new List(); public IEnumerable Validations => m_validations; - public static void CalcMeshSize(ref MeshUtility.MeshExportInfo info, + public static void CalcMeshSize(ref MeshExportInfo info, string relativePath, VRMExportSettings settings, IReadOnlyList clips) { var sb = new StringBuilder(); @@ -133,11 +134,11 @@ namespace VRM sb.Append($") x {info.Mesh.vertexCount}"); switch (info.VertexColor) { - case MeshUtility.MeshExportInfo.VertexColorState.ExistsAndIsUsed: - case MeshUtility.MeshExportInfo.VertexColorState.ExistsAndMixed: // エクスポートする + case MeshExportInfo.VertexColorState.ExistsAndIsUsed: + case MeshExportInfo.VertexColorState.ExistsAndMixed: // エクスポートする sb.Insert(0, "[use vcolor]"); break; - case MeshUtility.MeshExportInfo.VertexColorState.ExistsButNotUsed: + case MeshExportInfo.VertexColorState.ExistsButNotUsed: sb.Insert(0, "[remove vcolor]"); break; } @@ -151,7 +152,7 @@ namespace VRM info.Summary = sb.ToString(); } - bool TryGetMeshInfo(GameObject root, Renderer renderer, IReadOnlyList clips, VRMExportSettings settings, out MeshUtility.MeshExportInfo info) + bool TryGetMeshInfo(GameObject root, Renderer renderer, IReadOnlyList clips, VRMExportSettings settings, out MeshExportInfo info) { info = default; if (root == null) @@ -187,7 +188,7 @@ namespace VRM return false; } - info.VertexColor = MeshUtility.MeshExportInfo.DetectVertexColor(info.Mesh, info.Renderer.sharedMaterials); + info.VertexColor = MeshExportInfo.DetectVertexColor(info.Mesh, info.Renderer.sharedMaterials); var relativePath = UniGLTF.UnityExtensions.RelativePathFrom(renderer.transform, root.transform); CalcMeshSize(ref info, relativePath, settings, clips); @@ -217,7 +218,7 @@ namespace VRM foreach (var renderer in ExportRoot.GetComponentsInChildren(true)) { - if (TryGetMeshInfo(ExportRoot, renderer, clips, settings, out MeshUtility.MeshExportInfo info)) + if (TryGetMeshInfo(ExportRoot, renderer, clips, settings, out MeshExportInfo info)) { Meshes.Add(info); } diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMExportMeshesEditor.cs b/Assets/VRM/UniVRM/Editor/Format/VRMExportMeshesEditor.cs index b1f1383bd..e48bbfd51 100644 --- a/Assets/VRM/UniVRM/Editor/Format/VRMExportMeshesEditor.cs +++ b/Assets/VRM/UniVRM/Editor/Format/VRMExportMeshesEditor.cs @@ -32,7 +32,7 @@ namespace VRM ); } - void DrawElement(int i, MeshUtility.MeshExportInfo info) + void DrawElement(int i, UniGLTF.MeshExportInfo info) { var r = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.Height(EditorGUIUtility.singleLineHeight * 3 + 20)); var col0 = 32; diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMExporterWizard.cs b/Assets/VRM/UniVRM/Editor/Format/VRMExporterWizard.cs index 5609279f8..d422fe12f 100644 --- a/Assets/VRM/UniVRM/Editor/Format/VRMExporterWizard.cs +++ b/Assets/VRM/UniVRM/Editor/Format/VRMExporterWizard.cs @@ -95,7 +95,7 @@ namespace VRM // default setting m_settings.PoseFreeze = - MeshUtility.Validators.HumanoidValidator.HasRotationOrScale(root) + HumanoidValidator.HasRotationOrScale(root) || m_meshes.Meshes.Any(x => x.ExportBlendShapeCount > 0 && !x.HasSkinning) ; } @@ -153,8 +153,8 @@ namespace VRM IEnumerable ValidatorFactory() { - MeshUtility.Validators.HumanoidValidator.MeshInformations = m_meshes.Meshes; - MeshUtility.Validators.HumanoidValidator.EnableFreeze = m_settings.PoseFreeze; + HumanoidValidator.MeshInformations = m_meshes.Meshes; + HumanoidValidator.EnableFreeze = m_settings.PoseFreeze; VRMExporterValidator.ReduceBlendshape = m_settings.ReduceBlendshape; yield return MeshUtility.Validators.HierarchyValidator.Validate; @@ -163,7 +163,7 @@ namespace VRM yield break; } - yield return MeshUtility.Validators.HumanoidValidator.Validate; + yield return HumanoidValidator.Validate; yield return VRMExporterValidator.Validate; yield return VRMSpringBoneValidator.Validate; @@ -269,7 +269,7 @@ namespace VRM { switch (meshInfo.VertexColor) { - case MeshUtility.MeshExportInfo.VertexColorState.ExistsAndMixed: + case UniGLTF.MeshExportInfo.VertexColorState.ExistsAndMixed: MeshUtility.Validation.Warning($"{meshInfo.Renderer}: Both vcolor.multiply and not multiply unlit materials exist").DrawGUI(); break; } diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMVersionMenu.cs b/Assets/VRM/UniVRM/Editor/Format/VRMVersionMenu.cs index 006810561..d0cb3efd3 100644 --- a/Assets/VRM/UniVRM/Editor/Format/VRMVersionMenu.cs +++ b/Assets/VRM/UniVRM/Editor/Format/VRMVersionMenu.cs @@ -129,8 +129,7 @@ namespace VRM ""name"": ""VRM Consortium"" }}, ""dependencies"": {{ - ""com.vrmc.vrmshaders"": ""{1}"", - ""com.vrmc.meshutility"": ""{1}"" + ""com.vrmc.vrmshaders"": ""{1}"" }} }}");