From 567dd398726b5439a5b7dbfbcf02961048c40ef7 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Fri, 28 Aug 2020 15:08:05 +0900 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=9B=9EExport=E6=99=82=E3=81=AEmeta?= =?UTF-8?q?=E5=8F=97=E3=81=91=E6=B8=A1=E3=81=97=E6=96=B9=E6=B3=95=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20#528?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UniVRM/Editor/Format/VRMEditorExporter.cs | 18 +++++++++++++++--- .../UniVRM/Editor/Format/VRMExporterWizard.cs | 15 +-------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMEditorExporter.cs b/Assets/VRM/UniVRM/Editor/Format/VRMEditorExporter.cs index cf3b144d1..0e5902c8a 100644 --- a/Assets/VRM/UniVRM/Editor/Format/VRMEditorExporter.cs +++ b/Assets/VRM/UniVRM/Editor/Format/VRMEditorExporter.cs @@ -16,12 +16,12 @@ namespace VRM /// /// 出力先 /// エクスポート設定 - public static void Export(string path, GameObject exportRoot, VRMExportSettings settings) + public static void Export(string path, GameObject exportRoot, VRMMetaObject meta, VRMExportSettings settings) { List destroy = new List(); try { - Export(path, exportRoot, settings, destroy); + Export(path, exportRoot, meta, settings, destroy); } finally { @@ -136,7 +136,7 @@ namespace VRM /// /// /// 作業が終わったらDestoryするべき一時オブジェクト - static void Export(string path, GameObject exportRoot, VRMExportSettings settings, List destroy) + static void Export(string path, GameObject exportRoot, VRMMetaObject meta, VRMExportSettings settings, List destroy) { var target = exportRoot; @@ -144,6 +144,18 @@ namespace VRM target = GameObject.Instantiate(target); destroy.Add(target); + var metaBehaviour = target.GetComponent(); + if (metaBehaviour == null) + { + metaBehaviour = target.AddComponent(); + metaBehaviour.Meta = meta; + } + if (metaBehaviour.Meta == null) + { + // 来ないはず + throw new Exception("meta required"); + } + { // copy元 var animator = exportRoot.GetComponent(); diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMExporterWizard.cs b/Assets/VRM/UniVRM/Editor/Format/VRMExporterWizard.cs index 64c4284ed..efef21b56 100644 --- a/Assets/VRM/UniVRM/Editor/Format/VRMExporterWizard.cs +++ b/Assets/VRM/UniVRM/Editor/Format/VRMExporterWizard.cs @@ -695,20 +695,7 @@ namespace VRM m_lastExportDir = Path.GetDirectoryName(path).Replace("\\", "/"); // export - if (Meta == null) - { - var metaB = ExportRoot.GetComponent(); - if (metaB == null) - { - metaB = ExportRoot.AddComponent(); - } - metaB.Meta = m_tmpMeta; - } - VRMEditorExporter.Export(path, ExportRoot, m_settings); - if (Meta == null) - { - UnityEngine.GameObject.DestroyImmediate(ExportRoot.GetComponent()); - } + VRMEditorExporter.Export(path, ExportRoot, Meta != null ? Meta : m_tmpMeta, m_settings); } void OnWizardUpdate()