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()