From 423889cb05d12f7c3464491fe286e88a7743cbb5 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Fri, 11 Jun 2021 17:12:13 +0900 Subject: [PATCH] UnityObjectManager is not unnecessary for prefab --- .../Editor/UniGLTF/ScriptedImporter/ScriptedImporterImpl.cs | 6 ++++-- Assets/VRM/Editor/Format/VRMEditorImporterContext.cs | 6 ++++-- .../Editor/ScriptedImporter/VrmScriptedImporterImpl.cs | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/ScriptedImporterImpl.cs b/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/ScriptedImporterImpl.cs index 1bde54543..335dd3ef0 100644 --- a/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/ScriptedImporterImpl.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/ScriptedImporterImpl.cs @@ -55,9 +55,11 @@ namespace UniGLTF { context.AddObjectToAsset(k.Name, o); }); + var root = loaded.Root; + GameObject.DestroyImmediate(loaded); - context.AddObjectToAsset(loaded.name, loaded.gameObject); - context.SetMainObject(loaded.gameObject); + context.AddObjectToAsset(root.name, root); + context.SetMainObject(root); } } } diff --git a/Assets/VRM/Editor/Format/VRMEditorImporterContext.cs b/Assets/VRM/Editor/Format/VRMEditorImporterContext.cs index 8445c19f7..5ee95bc43 100644 --- a/Assets/VRM/Editor/Format/VRMEditorImporterContext.cs +++ b/Assets/VRM/Editor/Format/VRMEditorImporterContext.cs @@ -139,18 +139,20 @@ namespace VRM m_paths.Clear(); m_paths.Add(m_prefabPath); loaded.TransferOwnership(SaveAsAsset); + var root = loaded.Root; + GameObject.DestroyImmediate(loaded); // Create or update Main Asset if (m_prefabPath.IsFileExists) { Debug.LogFormat("replace prefab: {0}", m_prefabPath); var prefab = m_prefabPath.LoadAsset(); - PrefabUtility.SaveAsPrefabAssetAndConnect(loaded.gameObject, m_prefabPath.Value, InteractionMode.AutomatedAction); + PrefabUtility.SaveAsPrefabAssetAndConnect(root, m_prefabPath.Value, InteractionMode.AutomatedAction); } else { Debug.LogFormat("create prefab: {0}", m_prefabPath); - PrefabUtility.SaveAsPrefabAssetAndConnect(loaded.gameObject, m_prefabPath.Value, InteractionMode.AutomatedAction); + PrefabUtility.SaveAsPrefabAssetAndConnect(root, m_prefabPath.Value, InteractionMode.AutomatedAction); } foreach (var x in m_paths) diff --git a/Assets/VRM10/Editor/ScriptedImporter/VrmScriptedImporterImpl.cs b/Assets/VRM10/Editor/ScriptedImporter/VrmScriptedImporterImpl.cs index 65f4a94fc..334a1df38 100644 --- a/Assets/VRM10/Editor/ScriptedImporter/VrmScriptedImporterImpl.cs +++ b/Assets/VRM10/Editor/ScriptedImporter/VrmScriptedImporterImpl.cs @@ -49,9 +49,11 @@ namespace UniVRM10 { context.AddObjectToAsset(key.Name, o); }); + var root = loaded.Root; + GameObject.DestroyImmediate(loaded); - context.AddObjectToAsset(loaded.name, loaded.gameObject); - context.SetMainObject(loaded.gameObject); + context.AddObjectToAsset(root.name, root); + context.SetMainObject(root); } } }