예제 #1
0
        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();

            if (!PanelManagerWindow.IsWindowOpen)
            {
                if (GUILayout.Button("Open Panel Manager"))
                {
                    PanelManagerWindow.DoWindow();
                }
            }
        }
예제 #2
0
        public override void OnInspectorGUI()
        {
            var it = serializedObject.GetIterator();

            it.NextVisible(true);

            EditorGUILayout.PropertyField(it, true);

            EditorGUILayout.PropertyField(serializedObject.FindProperty("PanelType"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("PanelProperties"), true);

            eventsFoldout = EditorGUILayout.Foldout(eventsFoldout, "Events", true);

            if (eventsFoldout)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("OnPanelOpen"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("OnPanelOpenEnd"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("OnPanelClose"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("OnPanelCloseEnd"));
            }


            serializedObject.ApplyModifiedProperties();

            var prevColor = GUI.contentColor;

            GUI.contentColor = Color.red;

            GUI.contentColor = prevColor;
            WooPanel myScript = (WooPanel)target;

            if (myScript == null)
            {
                return;
            }

            var animator = myScript.gameObject.GetComponent <Animator>();

            if (targets.Length > 1)
            {
                return;
            }

            ProcessEffects();

            if (animator.runtimeAnimatorController == null || animator.runtimeAnimatorController.name == "Default Panel Controller")
            {
                var controllerName = target.name + " Controller.controller";

                if (GUILayout.Button("Create Mirrored \"" + controllerName + "\""))
                {
                    CreateMirroredAnimator(myScript.gameObject, controllerName);
                }

                if (GUILayout.Button("Create \"" + controllerName + "\""))
                {
                    CreateAnimator(myScript.gameObject, controllerName);
                }
            }
            else
            {
                bool found = false;

                if (!myScript.IsMirrored())
                {
                    if (GUILayout.Button("Make Open/Close mirrored"))
                    {
                        ConvertToMirrored();
                    }
                }
                else
                {
                    if (GUILayout.Button("Make Open/Close separate"))
                    {
                        ConvertToSeparate();
                    }
                }
                for (int i = 0; i < animator.runtimeAnimatorController.animationClips.Length; i++)
                {
                    var clip = animator.runtimeAnimatorController.animationClips[i];
                    if (clip.name == PANEL_OPENED_STATE)
                    {
                        found = true;
                    }
                }

                if (!found)
                {
                    if (GUILayout.Button("Add Mirrored states to controller"))
                    {
                        CreateAnimatorStates(animator.runtimeAnimatorController as AnimatorController, true);
                    }

                    if (GUILayout.Button("Add Open/Close states to controller"))
                    {
                        CreateAnimatorStates(animator.runtimeAnimatorController as AnimatorController);
                    }
                }
            }

            if (target.GetType() == typeof(WooPanel))
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Script Name: ");
                var prevScriptName = scriptName;
                if (!wasEdited)
                {
                    scriptName = target.name;
                }

                scriptName = GUILayout.TextField(scriptName);
                if (scriptName != prevScriptName)
                {
                    wasEdited = true;
                }
                bool exists = false;

                if (!File.Exists(GetFilePath(scriptName)))
                {
                    if (GUILayout.Button("Create \"" + GenerateFileName(scriptName) + "\""))
                    {
                        CreateScript(((WooPanel)target).gameObject, scriptName);
                    }
                }
                else
                {
                    if (GUILayout.Button("Replace with \"" + GenerateFileName(scriptName) + "\""))
                    {
                        CreateScript(((WooPanel)target).gameObject, scriptName);
                    }
                    exists = true;
                }

                GUILayout.EndHorizontal();

                var msg = "";

                if (waitForCompile)
                {
                    msg = "Please, wait while the script is compiling. It will add automatically.";
                }
                else if (exists)
                {
                    msg = "Script with this name already exists. ";
                }
                else
                {
                    msg = "Component will be created and will replace WooPanel on this gameobject.";
                }

                EditorGUILayout.HelpBox(msg, MessageType.Info);
            }

            if (waitForCompile)
            {
                if (!EditorApplication.isCompiling)
                {
                    if (shouldAddScript)
                    {
                        waitForCompile  = false;
                        shouldAddScript = false;
                        targetGameObject.AddComponent(System.Type.GetType(componentName + ",Assembly-CSharp"));
                        DestroyImmediate(targetGameObject.GetComponent <WooPanel>());

                        return;
                    }
                    shouldAddScript = true;
                }
            }

            if (!(target is GenericPanelEditor))
            {
                while (it.NextVisible(false))
                {
                    var name = it.name;

                    if (name != "PanelType" && name != "PanelProperties" &&
                        name != "OnPanelOpen" && name != "OnPanelOpenEnd" &&
                        name != "OnPanelClose" && name != "OnPanelCloseEnd")
                    {
                        EditorGUILayout.PropertyField(it, true);
                    }
                }
            }

            if (!PanelManagerWindow.IsWindowOpen)
            {
                if (GUILayout.Button("Open Panel Manager"))
                {
                    PanelManagerWindow.DoWindow();
                }
            }


            serializedObject.ApplyModifiedProperties();
        }