From 9f7ff245364eb00c145f440ad044ee9bce5ab7c5 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Tue, 14 Dec 2021 15:25:23 +0900 Subject: [PATCH] =?UTF-8?q?meta=20=E3=81=AE=20PropertyField=20=E3=81=AB?= =?UTF-8?q?=E5=AF=BE=E3=81=99=E3=82=8B=E3=82=AA=E3=83=96=E3=82=B8=E3=82=A7?= =?UTF-8?q?=E3=82=AF=E3=83=88=E7=BD=AE=E3=81=8D=E6=8F=9B=E3=81=88=E3=82=92?= =?UTF-8?q?=E6=9C=89=E5=8A=B9=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/VRM/Editor/Meta/VRMMetaEditor.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Assets/VRM/Editor/Meta/VRMMetaEditor.cs b/Assets/VRM/Editor/Meta/VRMMetaEditor.cs index d1b83251c..c7ca40404 100644 --- a/Assets/VRM/Editor/Meta/VRMMetaEditor.cs +++ b/Assets/VRM/Editor/Meta/VRMMetaEditor.cs @@ -10,11 +10,16 @@ namespace VRM Editor m_Inspector; SerializedProperty m_VRMMetaObjectProp; - private void OnDestroy() + void DestroyEditor() { UnityEditor.Editor.DestroyImmediate(m_Inspector); } + private void OnDestroy() + { + DestroyEditor(); + } + private void OnEnable() { m_target = target as VRMMeta; @@ -27,7 +32,17 @@ namespace VRM public override void OnInspectorGUI() { + serializedObject.Update(); + var old = m_VRMMetaObjectProp.objectReferenceValue; EditorGUILayout.PropertyField(m_VRMMetaObjectProp); + if (m_VRMMetaObjectProp.objectReferenceValue != old) + { + // updated + serializedObject.ApplyModifiedProperties(); + DestroyEditor(); + m_Inspector = Editor.CreateEditor(m_VRMMetaObjectProp.objectReferenceValue); + } + if (m_Inspector != null) { m_Inspector.OnInspectorGUI();