Пример #1
0
        public static void OpenWindow()
        {
            TEA_Settings settings            = TEA_EditorUtility.GetTEA_Settings();
            TEA_Settings_EditorWindow window = EditorWindow.GetWindow(typeof(TEA_Settings_EditorWindow), false, "TEA Settings", true) as TEA_Settings_EditorWindow;

            window.minSize = new Vector2(300, 300);
            window.editor  = Editor.CreateEditorWithContext(new Object[] { settings }, settings);
        }
Пример #2
0
        private void OnGUI()
        {
            if (null == settings)
            {
                return;
            }

            try {
                if (null == imageStyle)
                {
                    imageStyle = new GUIStyle()
                    {
                        alignment = TextAnchor.UpperLeft
                    };
                }
                if (null == layoutStyle)
                {
                    layoutStyle = new GUIStyle(EditorStyles.boldLabel)
                    {
                        alignment   = TextAnchor.MiddleCenter,
                        fixedHeight = MIN_HEIGHT
                    };
                }
                if (null == sectionStyle)
                {
                    sectionStyle = new GUIStyle(EditorStyles.helpBox)
                    {
                        padding = this.padding
                    };
                }

                EditorGUILayout.BeginHorizontal();
                //------
                if (EditorApplication.isPlaying && !_compiled)
                {
                    if (null != manager)
                    {
                        manager.gameObject.SetActive(false);
                    }
                    EditorGUILayout.HelpBox("TEA Manager will not activate unless you use the custom play/validate buttons", MessageType.Warning);
                    return;
                }

                if (_managerOverload)
                {
                    EditorGUILayout.HelpBox($"Only one TEA Manager can be loaded at a time, please delete one form the Active Scene", MessageType.Error);
                    EndLayout();
                    return;
                }

                if (GUILayout.Button("Settings", GUILayout.Width(SECTION_WIDTH / 3)))
                {
                    TEA_Settings_EditorWindow.OpenWindow();
                }

                DrawToggleParent();
                EditorGUILayout.LabelField("", GUI.skin.verticalSlider, GUILayout.Width(SEPARATOR_WIDTH), GUILayout.Height(MIN_HEIGHT));

                if (!_avatars)
                {
                    DrawButtonParent(false);
                    DrawInfoParent(DrawNoAvatars, SECTION_WIDTH * 2);
                    //TODO add list of potential avatar?
                    EndLayout();
                    return;
                }
                else if (null == manager)
                {
                    DrawButtonParent(true);
                    DrawInfoParent(DrawNoManagers, SECTION_WIDTH * 2);
                    EndLayout();
                    return;
                }

                if (null != manager && !EditorApplication.isPlaying && PrefabUtility.IsAnyPrefabInstanceRoot(manager.gameObject))
                {
                    PrefabUtility.UnpackPrefabInstance(manager.gameObject, PrefabUnpackMode.Completely, InteractionMode.AutomatedAction);
                    Debug.Log("Automatically unpacked TEA Manager");
                }

                // --- buttons
                DrawButtonParent(true);

                if (EditorApplication.isPlaying)
                {
                    DrawInfoParent(DrawSelector, SECTION_WIDTH);
                }
                else
                {
                    DrawInfoParent(DrawWaiting, SECTION_WIDTH);
                }


                //----------------
                EndLayout();

                EditorGUILayout.BeginVertical();

                EditorGUILayout.EndVertical();

                CleanLeanTween();
            } catch (System.Exception ex) {
                Debug.LogException(new System.Exception("Play Tab ran into an unexpected issue", ex));
            }
        }