diff --git a/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/ExportDialogBase.cs b/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/ExportDialogBase.cs index 30034f70b3..7564ea58ac 100644 --- a/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/ExportDialogBase.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/ExportDialogBase.cs @@ -77,10 +77,8 @@ static BeginVerticalScrollViewFunc BeginVerticalScrollView void OnGUI() { var modified = false; - if (BeginGUI()) - { - modified = DoGUI(); - } + var isValid = BeginGUI(); + modified = DoGUI(isValid); EndGUI(); if (modified) @@ -89,7 +87,7 @@ void OnGUI() } } - 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 86fcd285a7..8152677ee1 100644 --- a/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/GltfExportWindow.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/GltfExportWindow.cs @@ -50,8 +50,13 @@ protected override IEnumerable ValidatorFactory() 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/InternalTPose.cs b/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/InternalTPose.cs similarity index 86% rename from Assets/VRM/Editor/Format/InternalTPose.cs rename to Assets/UniGLTF/Editor/UniGLTF/ExportDialog/InternalTPose.cs index bf3b4cca9b..703068203e 100644 --- a/Assets/VRM/Editor/Format/InternalTPose.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/InternalTPose.cs @@ -2,11 +2,22 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using UniGLTF; +using UniGLTF.M17N; using UnityEngine; -namespace VRM +namespace UniGLTF { + public enum EnableTPose + { + [LangMsg(Languages.ja, "このボタンで自動で T-Pose にできます。手動で T-Pose にしたり、ボタンの後で手直ししてもOKです。")] + [LangMsg(Languages.en, "T-Pose can be made automatically with this button, or you can make the model as T-Pose manually. Adjusting T-Pose manually after applying this function is also OK")] + ENALBE_TPOSE_BUTTON, + + [LangMsg(Languages.ja, "このボタンで自動で T-Pose にできます。prefab には実行できません。")] + [LangMsg(Languages.en, "T-Pose can be made automatically with this button. It cannot be run on prefabs.")] + DISABLE_TPOSE_BUTTON, + } + public static class InternalTPose { struct TRS diff --git a/Assets/VRM/Editor/Format/InternalTPose.cs.meta b/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/InternalTPose.cs.meta similarity index 83% rename from Assets/VRM/Editor/Format/InternalTPose.cs.meta rename to Assets/UniGLTF/Editor/UniGLTF/ExportDialog/InternalTPose.cs.meta index acfd503fc0..87587273cf 100644 --- a/Assets/VRM/Editor/Format/InternalTPose.cs.meta +++ b/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/InternalTPose.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 42e52c1a93301da4eb0435ed00bdf8c4 +guid: 5af5e8f17a650a849bb2cde54c4cd8a5 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/VRM/Editor/Format/VRMExportSettingsEditor.cs b/Assets/VRM/Editor/Format/VRMExportSettingsEditor.cs index d805c98098..a802191611 100644 --- a/Assets/VRM/Editor/Format/VRMExportSettingsEditor.cs +++ b/Assets/VRM/Editor/Format/VRMExportSettingsEditor.cs @@ -2,10 +2,6 @@ using System; using UnityEditor; using UnityEngine; -using System.Reflection; -using System.Linq; -using System.Collections.Generic; -using UniGLTF; using UniGLTF.M17N; namespace VRM @@ -86,14 +82,6 @@ public enum Options [LangMsg(Languages.en, "Vertex color will not be exported")] REMOVE_VERTEX_COLOR, - [LangMsg(Languages.ja, "このボタンで自動で T-Pose にできます。手動で T-Pose にしたり、ボタンの後で手直ししてもOKです。")] - [LangMsg(Languages.en, "T-Pose can be made automatically with this button, or you can make the model as T-Pose manually. Adjusting T-Pose manually after applying this function is also OK")] - ENALBE_TPOSE_BUTTON, - - [LangMsg(Languages.ja, "このボタンで自動で T-Pose にできます。prefab には実行できません。")] - [LangMsg(Languages.en, "T-Pose can be made automatically with this button. It cannot be run on prefabs.")] - DISABLE_TPOSE_BUTTON, - [LangMsg(Languages.ja, "T-Pose にする")] [LangMsg(Languages.en, "Make T-Pose")] DO_TPOSE, @@ -119,48 +107,6 @@ public override void OnInspectorGUI() GUILayout.Space(20); var settings = (VRMExportSettings)target; var root = settings.Root; - var backup = GUI.enabled; - GUI.enabled = root.scene.IsValid(); - if (GUI.enabled) - { - EditorGUILayout.HelpBox(Options.ENALBE_TPOSE_BUTTON.Msg(), MessageType.Info); - } - else - { - EditorGUILayout.HelpBox(Options.DISABLE_TPOSE_BUTTON.Msg(), MessageType.Warning); - } - - // - // T-Pose - // - if (GUILayout.Button(VRMExportSettingsEditor.Options.DO_TPOSE.Msg())) - { - if (settings.Root != null) - { - // fallback - Undo.RecordObjects(settings.Root.GetComponentsInChildren(), "tpose"); - VRMBoneNormalizer.EnforceTPose(settings.Root); - } - } - - if (GUILayout.Button(VRMExportSettingsEditor.Options.DO_TPOSE.Msg() + "(unity internal)")) - { - if (settings.Root != null) - { - Undo.RecordObjects(settings.Root.GetComponentsInChildren(), "tpose.internal"); - if (InternalTPose.TryMakePoseValid(settings.Root)) - { - // done - } - else - { - Debug.LogWarning("not found"); - } - } - } - - GUI.enabled = backup; - GUILayout.Space(20); // ToDo: 任意の BlendShapeClip を適用する diff --git a/Assets/VRM/Editor/Format/VRMExporterWizard.cs b/Assets/VRM/Editor/Format/VRMExporterWizard.cs index 878958efc1..c8905f25f4 100644 --- a/Assets/VRM/Editor/Format/VRMExporterWizard.cs +++ b/Assets/VRM/Editor/Format/VRMExporterWizard.cs @@ -175,10 +175,71 @@ protected override void OnLayout() 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 // diff --git a/Assets/VRM10/Editor/Vrm10ExportDialog.cs b/Assets/VRM10/Editor/Vrm10ExportDialog.cs index 17778c7f1c..556dd5b447 100644 --- a/Assets/VRM10/Editor/Vrm10ExportDialog.cs +++ b/Assets/VRM10/Editor/Vrm10ExportDialog.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using UniGLTF; +using UniGLTF.M17N; using UnityEditor; using UnityEngine; using VrmLib; @@ -134,36 +135,64 @@ protected override IEnumerable ValidatorFactory() yield return meta.Validate; } - // private void OnGUI() - // { - // { - // var path = SaveFileDialog.GetPath("Save vrm1", $"{State.ExportRoot.name}.vrm", "vrm"); - // if (!string.IsNullOrEmpty(path)) - // { - // // export - // Export(State.ExportRoot, path); - // // close - // Close(); - // GUIUtility.ExitGUI(); - // } - // } - // GUI.enabled = true; - - // GUILayout.EndHorizontal(); - // } - // GUILayout.EndVertical(); - // } - - // GUILayout.Space(8); - - // if (modified) - // { - // State.Invalidate(); - // } - // } - - 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