From 9855686ec3ef7f488d1a51c993ca257dea5bdbcd Mon Sep 17 00:00:00 2001 From: ousttrue Date: Wed, 11 May 2022 17:10:44 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=B3=E3=83=BC=E3=83=89=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Editor/MeshUtility/TabMeshIntegrator.cs | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/Assets/UniGLTF/Editor/MeshUtility/TabMeshIntegrator.cs b/Assets/UniGLTF/Editor/MeshUtility/TabMeshIntegrator.cs index 758d77a8b..209437698 100644 --- a/Assets/UniGLTF/Editor/MeshUtility/TabMeshIntegrator.cs +++ b/Assets/UniGLTF/Editor/MeshUtility/TabMeshIntegrator.cs @@ -26,7 +26,7 @@ namespace UniGLTF.MeshUtility return _isInvokeSuccess; } - static string VRM_META = "VRMMeta"; + const string VRM_META = "VRMMeta"; static bool HasVrm(GameObject root) { var allComponents = root.GetComponents(typeof(Component)); @@ -62,27 +62,23 @@ namespace UniGLTF.MeshUtility return false; } - MeshIntegrator(root); + MeshIntegratorUtility.Integrate(root, onlyBlendShapeRenderers: true); + MeshIntegratorUtility.Integrate(root, onlyBlendShapeRenderers: false); + + CopyAndSaveAssetEtc(root); + return true; } - /// - /// from dialog - /// - /// - public static void MeshIntegrator(GameObject go) + static void CopyAndSaveAssetEtc(GameObject root) { - MeshIntegratorUtility.Integrate(go, onlyBlendShapeRenderers: true); - MeshIntegratorUtility.Integrate(go, onlyBlendShapeRenderers: false); - - var outputObject = GameObject.Instantiate(go); + // copy hierarchy + var outputObject = GameObject.Instantiate(root); outputObject.name = outputObject.name + "_mesh_integration"; var skinnedMeshes = outputObject.GetComponentsInChildren(); - var normalMeshes = outputObject.GetComponentsInChildren(); // destroy integrated meshes in the source - // ? - foreach (var skinnedMesh in go.GetComponentsInChildren()) + foreach (var skinnedMesh in root.GetComponentsInChildren()) { if (skinnedMesh.sharedMesh.name == MeshIntegratorUtility.INTEGRATED_MESH_NAME || skinnedMesh.sharedMesh.name == MeshIntegratorUtility.INTEGRATED_MESH_BLENDSHAPE_NAME) @@ -110,6 +106,8 @@ namespace UniGLTF.MeshUtility SaveMeshData(skinnedMesh.sharedMesh); } } + + var normalMeshes = outputObject.GetComponentsInChildren(); foreach (var normalMesh in normalMeshes) { if (normalMesh.sharedMesh.name != MeshIntegratorUtility.INTEGRATED_MESH_NAME)