예제 #1
0
        bool DrawWizardGUI()
        {
            if (m_tmpMeta == null)
            {
                // disabled
                return(false);
            }

            // tabbar
            _tab = TabBar.OnGUI(_tab, TabButtonStyle, TabButtonSize);
            switch (_tab)
            {
            case Tabs.Meta:
                if (m_metaEditor == null)
                {
                    if (m_meta != null)
                    {
                        m_metaEditor = Editor.CreateEditor(Meta);
                    }
                    else
                    {
                        m_metaEditor = Editor.CreateEditor(m_tmpMeta);
                    }
                }
                m_metaEditor.OnInspectorGUI();
                break;

            case Tabs.ExportSettings:
                m_Inspector.OnInspectorGUI();
                break;
            }

            return(true);
        }
예제 #2
0
        private void OnGUI()
        {
            if (m_tmpMeta == null)
            {
                // OnDisable
                return;
            }

            EditorGUIUtility.labelWidth = 150;

            // lang
            M17N.Getter.OnGuiSelectLang();

            EditorGUILayout.LabelField("ExportRoot");
            {
                var root = (GameObject)EditorGUILayout.ObjectField(ExportRoot, typeof(GameObject), true);
                UpdateRoot(root);
            }

            // ArgumentException: Getting control 1's position in a group with only 1 controls when doing repaint Aborting
            // Validation により GUI の表示項目が変わる場合があるので、
            // EventType.Layout と EventType.Repaint 間で内容が変わらないようしている。
            if (Event.current.type == EventType.Layout)
            {
                Validate();
            }

            //
            // Humanoid として適正か? ここで失敗する場合は Export UI を表示しない
            //
            if (!m_validator.RootAndHumanoidCheck(ExportRoot, m_settings, m_meshes.Meshes))
            {
                return;
            }

            EditorGUILayout.HelpBox($"Mesh size: {m_meshes.ExpectedExportByteSize / 1000000.0f:0.0} MByte", MessageType.Info);
            _tab = TabBar.OnGUI(_tab, TabButtonStyle, TabButtonSize);

            // Render contents using Generic Inspector GUI
            m_ScrollPosition = BeginVerticalScrollView(m_ScrollPosition, false, GUI.skin.verticalScrollbar, "OL Box");
            GUIUtility.GetControlID(645789, FocusType.Passive);

            //
            // VRM の Validation
            //
            foreach (var v in m_validator.Validations)
            {
                v.DrawGUI();
            }
            foreach (var meshInfo in m_meshes.Meshes)
            {
                switch (meshInfo.VertexColor)
                {
                case UniGLTF.MeshExportInfo.VertexColorState.ExistsAndMixed:
                    Validation.Warning($"{meshInfo.Renderer}: Both vcolor.multiply and not multiply unlit materials exist").DrawGUI();
                    break;
                }
            }

            bool modified = DrawWizardGUI();

            EditorGUILayout.EndScrollView();

            // Create and Other Buttons
            {
                // errors
                GUILayout.BeginVertical();
                // GUILayout.FlexibleSpace();

                {
                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    GUI.enabled = m_validator.IsValid;

                    if (GUILayout.Button("Export", GUILayout.MinWidth(100)))
                    {
                        OnWizardCreate();
                        Close();
                        GUIUtility.ExitGUI();
                    }
                    GUI.enabled = true;

                    GUILayout.EndHorizontal();
                }
                GUILayout.EndVertical();
            }

            GUILayout.Space(8);

            if (modified)
            {
                m_requireValidation = true;
                Repaint();
            }
        }
예제 #3
0
        protected override bool DoGUI(bool isValid)
        {
            if (State.ExportRoot == null)
            {
                return(false);
            }

            //
            // T-Pose
            //
            if (State.ExportRoot.GetComponent <Animator>() != null)
            {
                var backup = GUI.enabled;
                GUI.enabled = State.ExportRoot.scene.IsValid();

                if (s_foldT = EditorGUILayout.Foldout(s_foldT, "T-Pose"))
                {
                    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 <Transform>(), "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 <Transform>(), "tpose.internal");
                            if (InternalTPose.TryMakePoseValid(State.ExportRoot))
                            {
                                // done
                                Repaint();
                            }
                            else
                            {
                                Debug.LogWarning("not found");
                            }
                        }
                    }
                }

                GUI.enabled = backup;
            }

            if (!isValid)
            {
                return(false);
            }

            //
            // GUI
            //
            _tab = TabBar.OnGUI(_tab);
            foreach (var meshInfo in m_meshes.Meshes)
            {
                switch (meshInfo.VertexColor)
                {
                case UniGLTF.VertexColorState.ExistsAndMixed:
                    Validation.Warning($"{meshInfo.Renderers}: Both vcolor.multiply and not multiply unlit materials exist").DrawGUI();
                    break;
                }
            }
            return(DrawWizardGUI());
        }
예제 #4
0
        private void OnGUI()
        {
            if (m_tmpMeta == null)
            {
                // OnDisable
                return;
            }

            EditorGUIUtility.labelWidth = 150;

            // lang
            M17N.Getter.OnGuiSelectLang();

            EditorGUILayout.LabelField("ExportRoot");
            {
                var root = (GameObject)EditorGUILayout.ObjectField(ExportRoot, typeof(GameObject), true);
                UpdateRoot(root);
            }

            if (Event.current.type == EventType.Layout)
            {
                // ArgumentException: Getting control 1's position in a group with only 1 controls when doing repaint Aborting
                // Validation により GUI の表示項目が変わる場合があるので、
                // EventType.Layout と EventType.Repaint 間で内容が変わらないようしている。
                if (m_requireValidation)
                {
                    m_validator.Validate(ExportRoot, m_settings, Meta != null ? Meta : m_tmpMeta);
                    m_requireValidation = false;
                }
            }

            //
            // Humanoid として適正か? ここで失敗する場合は Export UI を表示しない
            //
            if (!m_validator.RootAndHumanoidCheck(ExportRoot, m_settings))
            {
                return;
            }

            EditorGUILayout.HelpBox($"Mesh size: {m_validator.ExpectedByteSize / 1000000.0f:0.0} MByte", MessageType.Info);

            _tab = TabBar.OnGUI(_tab, TabButtonStyle, TabButtonSize);

            // Render contents using Generic Inspector GUI
            m_ScrollPosition = BeginVerticalScrollView(m_ScrollPosition, false, GUI.skin.verticalScrollbar, "OL Box");
            GUIUtility.GetControlID(645789, FocusType.Passive);

            //
            // VRM の Validation
            //
            foreach (var v in m_validator.Validations)
            {
                v.DrawGUI();
            }

            bool modified = DrawWizardGUI();

            EditorGUILayout.EndScrollView();

            // Create and Other Buttons
            {
                // errors
                GUILayout.BeginVertical();
                // GUILayout.FlexibleSpace();

                {
                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    GUI.enabled = m_validator.IsValid;

                    const BindingFlags kInstanceInvokeFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy;
                    if (m_OtherButton != "" && GUILayout.Button(m_OtherButton, GUILayout.MinWidth(100)))
                    {
                        MethodInfo method = GetType().GetMethod("OnWizardOtherButton", kInstanceInvokeFlags);
                        if (method != null)
                        {
                            method.Invoke(this, null);
                            GUIUtility.ExitGUI();
                        }
                        else
                        {
                            Debug.LogError("OnWizardOtherButton has not been implemented in script");
                        }
                    }

                    if (m_CreateButton != "" && GUILayout.Button(m_CreateButton, GUILayout.MinWidth(100)))
                    {
                        MethodInfo method = GetType().GetMethod("OnWizardCreate", kInstanceInvokeFlags);
                        if (method != null)
                        {
                            method.Invoke(this, null);
                        }
                        else
                        {
                            Debug.LogError("OnWizardCreate has not been implemented in script");
                        }
                        Close();
                        GUIUtility.ExitGUI();
                    }
                    GUI.enabled = true;

                    GUILayout.EndHorizontal();
                }
                GUILayout.EndVertical();
            }

            GUILayout.Space(8);

            if (modified)
            {
                m_requireValidation = true;
                Repaint();
            }
        }