diff --git a/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/ExportDialogBase.cs b/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/ExportDialogBase.cs index 30034f70b..7564ea58a 100644 --- a/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/ExportDialogBase.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/ExportDialogBase.cs @@ -77,10 +77,8 @@ namespace UniGLTF void OnGUI() { var modified = false; - if (BeginGUI()) - { - modified = DoGUI(); - } + var isValid = BeginGUI(); + modified = DoGUI(isValid); EndGUI(); if (modified) @@ -89,7 +87,7 @@ namespace UniGLTF } } - protected abstract bool DoGUI(); + protected abstract bool DoGUI(bool isValid); protected virtual void OnLayout() { diff --git a/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/GltfExportWindow.cs b/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/GltfExportWindow.cs index 86fcd285a..8152677ee 100644 --- a/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/GltfExportWindow.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/GltfExportWindow.cs @@ -50,8 +50,13 @@ namespace UniGLTF yield break; } } - protected override bool DoGUI() + protected override bool DoGUI(bool isValid) { + if (!isValid) + { + return false; + } + m_settings.Root = State.ExportRoot; m_settingsInspector.OnInspectorGUI(); return true; diff --git a/Assets/VRM/Editor/Format/VRMExporterWizard.cs b/Assets/VRM/Editor/Format/VRMExporterWizard.cs index aae3e0c38..c8905f25f 100644 --- a/Assets/VRM/Editor/Format/VRMExporterWizard.cs +++ b/Assets/VRM/Editor/Format/VRMExporterWizard.cs @@ -24,7 +24,6 @@ namespace VRM { Meta, Mesh, - Humanoid, BlendShape, ExportSettings, } @@ -176,10 +175,71 @@ namespace VRM m_meshes.SetRoot(State.ExportRoot, m_settings); } - protected override bool DoGUI() + protected override bool DoGUI(bool isValid) { + if (State.ExportRoot == null) + { + return false; + } + + // + // T-Pose + // + if (State.ExportRoot.GetComponent() != null) + { + var backup = GUI.enabled; + GUI.enabled = State.ExportRoot.scene.IsValid(); + if (GUI.enabled) + { + EditorGUILayout.HelpBox(EnableTPose.ENALBE_TPOSE_BUTTON.Msg(), MessageType.Info); + } + else + { + EditorGUILayout.HelpBox(EnableTPose.DISABLE_TPOSE_BUTTON.Msg(), MessageType.Warning); + } + + // + // T-Pose + // + if (GUILayout.Button(VRMExportSettingsEditor.Options.DO_TPOSE.Msg())) + { + if (State.ExportRoot != null) + { + // fallback + Undo.RecordObjects(State.ExportRoot.GetComponentsInChildren(), "tpose"); + VRMBoneNormalizer.EnforceTPose(State.ExportRoot); + Repaint(); + } + } + + if (GUILayout.Button(VRMExportSettingsEditor.Options.DO_TPOSE.Msg() + "(unity internal)")) + { + if (State.ExportRoot != null) + { + Undo.RecordObjects(State.ExportRoot.GetComponentsInChildren(), "tpose.internal"); + if (InternalTPose.TryMakePoseValid(State.ExportRoot)) + { + // done + Repaint(); + } + else + { + Debug.LogWarning("not found"); + } + } + } + + GUI.enabled = backup; + } + + if (!isValid) + { + return false; + } + EditorGUILayout.HelpBox($"Mesh size: {m_meshes.ExpectedExportByteSize / 1000000.0f:0.0} MByte", MessageType.Info); + // // GUI // @@ -226,52 +286,6 @@ namespace VRM m_meshesInspector.OnInspectorGUI(); break; - case Tabs.Humanoid: - { - var backup = GUI.enabled; - GUI.enabled = State.ExportRoot.scene.IsValid(); - if (GUI.enabled) - { - EditorGUILayout.HelpBox(EnableTPose.ENALBE_TPOSE_BUTTON.Msg(), MessageType.Info); - } - else - { - EditorGUILayout.HelpBox(EnableTPose.DISABLE_TPOSE_BUTTON.Msg(), MessageType.Warning); - } - - // - // T-Pose - // - if (GUILayout.Button(VRMExportSettingsEditor.Options.DO_TPOSE.Msg())) - { - if (State.ExportRoot != null) - { - // fallback - Undo.RecordObjects(State.ExportRoot.GetComponentsInChildren(), "tpose"); - VRMBoneNormalizer.EnforceTPose(State.ExportRoot); - } - } - - if (GUILayout.Button(VRMExportSettingsEditor.Options.DO_TPOSE.Msg() + "(unity internal)")) - { - if (State.ExportRoot != null) - { - Undo.RecordObjects(State.ExportRoot.GetComponentsInChildren(), "tpose.internal"); - if (InternalTPose.TryMakePoseValid(State.ExportRoot)) - { - // done - } - else - { - Debug.LogWarning("not found"); - } - } - } - - GUI.enabled = backup; - } - break; - case Tabs.BlendShape: if (State.ExportRoot) { diff --git a/Assets/VRM10/Editor/Vrm10ExportDialog.cs b/Assets/VRM10/Editor/Vrm10ExportDialog.cs index 083345b31..556dd5b44 100644 --- a/Assets/VRM10/Editor/Vrm10ExportDialog.cs +++ b/Assets/VRM10/Editor/Vrm10ExportDialog.cs @@ -26,7 +26,6 @@ namespace UniVRM10 { Meta, Mesh, - Humanoid, ExportSettings, } Tabs _tab; @@ -136,8 +135,64 @@ namespace UniVRM10 yield return meta.Validate; } - protected override bool DoGUI() + protected override bool DoGUI(bool isValid) { + if (State.ExportRoot == null) + { + return false; + } + + if (State.ExportRoot.GetComponent() != null) + { + // + // T-Pose + // + // if (GUILayout.Button("T-Pose")) + // { + // if (State.ExportRoot != null) + // { + // // fallback + // Undo.RecordObjects(State.ExportRoot.GetComponentsInChildren(), "tpose"); + // VRMBoneNormalizer.EnforceTPose(State.ExportRoot); + // } + // } + + var backup = GUI.enabled; + GUI.enabled = State.ExportRoot.scene.IsValid(); + if (GUI.enabled) + { + EditorGUILayout.HelpBox(EnableTPose.ENALBE_TPOSE_BUTTON.Msg(), MessageType.Info); + } + else + { + EditorGUILayout.HelpBox(EnableTPose.DISABLE_TPOSE_BUTTON.Msg(), MessageType.Warning); + } + + if (GUILayout.Button("T-Pose" + "(unity internal)")) + { + if (State.ExportRoot != null) + { + Undo.RecordObjects(State.ExportRoot.GetComponentsInChildren(), "tpose.internal"); + if (InternalTPose.TryMakePoseValid(State.ExportRoot)) + { + // done + Repaint(); + } + else + { + Debug.LogWarning("not found"); + } + } + } + + GUI.enabled = backup; + } + + if (!isValid) + { + return false; + } + if (m_tmpMeta == null) { // disabled @@ -170,52 +225,6 @@ namespace UniVRM10 case Tabs.Mesh: // m_meshesInspector.OnInspectorGUI(); break; - - case Tabs.Humanoid: - { - // - // T-Pose - // - // if (GUILayout.Button("T-Pose")) - // { - // if (State.ExportRoot != null) - // { - // // fallback - // Undo.RecordObjects(State.ExportRoot.GetComponentsInChildren(), "tpose"); - // VRMBoneNormalizer.EnforceTPose(State.ExportRoot); - // } - // } - - var backup = GUI.enabled; - GUI.enabled = State.ExportRoot.scene.IsValid(); - if (GUI.enabled) - { - EditorGUILayout.HelpBox(EnableTPose.ENALBE_TPOSE_BUTTON.Msg(), MessageType.Info); - } - else - { - EditorGUILayout.HelpBox(EnableTPose.DISABLE_TPOSE_BUTTON.Msg(), MessageType.Warning); - } - - if (GUILayout.Button("T-Pose" + "(unity internal)")) - { - if (State.ExportRoot != null) - { - Undo.RecordObjects(State.ExportRoot.GetComponentsInChildren(), "tpose.internal"); - if (InternalTPose.TryMakePoseValid(State.ExportRoot)) - { - // done - } - else - { - Debug.LogWarning("not found"); - } - } - } - - GUI.enabled = backup; - } - break; } return true;