void OnGUI()
        {
            if (animators.Count == 0)
            {
                FindAnimationControllers();
            }

            using (EditorGUILayoutEx.ScrollView(ref m_ScrollPosition))
            {
                using (GUILayoutEx.Horizontal())
                {
                    GUILayout.Label(EditorApplication.isPlaying ? "Runtime Animator Controllers:" : "Project Animator Controllers:", EditorStyles.boldLabel);
                    if (GUILayout.Button("Refresh", GUILayout.Width(80)))
                    {
                        FindAnimationControllers();
                    }
                }

                FieldInfo    m_PreviewAnimator    = m_AnimatorControllerToolType.GetField("m_PreviewAnimator", BindingFlags.Instance | BindingFlags.NonPublic);
                PropertyInfo m_AnimatorController = m_AnimatorControllerToolType.GetProperty("animatorController", BindingFlags.Instance | BindingFlags.Public);

                foreach (var a in animators)
                {
                    using (GUILayoutEx.Horizontal())
                    {
                        if (a.animator == null)
                        {
                            if (GUILayout.Button("{0}".format(a.controller.name), GUILayout.Height(20)))
                            {
                                EditorWindow m_AnimatorControllerTool = GetWindow(m_AnimatorControllerToolType);
                                m_AnimatorController.SetValue(m_AnimatorControllerTool, a.controller, null);
                                m_AnimatorControllerTool.Repaint();
                            }
                            if (GUILayout.Button(new GUIContent("S", "Show animator in hierarchy view."), GUILayout.Width(20)))
                            {
                                EditorGUIUtility.PingObject(AssetDatabase.LoadMainAssetAtPath(a.path));
                            }
                        }
                        else
                        {
                            if (GUILayout.Button("{0}: {1}".format(a.animator.name, a.controller.name), GUILayout.Height(20)))
                            {
                                EditorWindow m_AnimatorControllerTool = GetWindow(m_AnimatorControllerToolType);
                                m_PreviewAnimator.SetValue(m_AnimatorControllerTool, a.animator);
                                m_AnimatorController.SetValue(m_AnimatorControllerTool, a.controller, null);
                                m_AnimatorControllerTool.Repaint();
                            }
                            if (GUILayout.Button(new GUIContent("S", "Show animator in hierarchy view."), GUILayout.Width(20)))
                            {
                            }
                        }
                    }
                }
            }
        }
Example #2
0
        void OnGUI()
        {
            if (settings == null)
            {
                UnityEngine.Object[] objectArray = InternalEditorUtility.LoadSerializedFileAndForget(m_SettingsPath);
                if (objectArray != null && objectArray.Length > 0)
                {
                    settings = objectArray[0] as UnityExSettings;
                }
                if (settings == null)
                {
                    settings           = CreateInstance <UnityExSettings>();
                    settings.hideFlags = HideFlags.DontSave;
                    settings.name      = "UnityEx Settings";
                    settings.buildName = "Release";
                    InternalEditorUtility.SaveToSerializedFileAndForget(new UnityEngine.Object[1] {
                        settings
                    }, m_SettingsPath, true);
                }

                CheckPaths();
            }

            bool bIsDirty = false;

            EditorGUILayout.Space();

            GUILayout.Label("Project namespace:", EditorStyles.boldLabel);
            using (EditorGUIEx.ChangeCheck(() => UnityEditorExSettings.instance.Save()))
            {
                UnityEditorExSettings.instance.namespaceName = EditorGUILayout.TextField(UnityEditorExSettings.instance.namespaceName);
            }

            GUILayout.Label("Project editor source path:", EditorStyles.boldLabel);
            using (EditorGUIEx.ChangeCheck(() => UnityEditorExSettings.instance.Save()))
            {
                UnityEditorExSettings.instance.editorScriptsPath = EditorGUILayout.TextField(UnityEditorExSettings.instance.editorScriptsPath);
            }

            GUILayout.Label("UnityEx solution path:", EditorStyles.boldLabel);
            using (EditorGUIEx.ChangeCheck(() => bIsDirty = true))
            {
                settings.solutionPath = EditorGUILayout.TextField(settings.solutionPath);
            }
            if (bIsDirty)
            {
                CheckPaths();
            }

            if (EditorGUILayout.DropdownButton(new GUIContent(settings.buildName), FocusType.Keyboard))
            {
                GenericMenu menu = new GenericMenu();

                menu.AddItem(new GUIContent("Release"), settings.buildName == "Release", () => { settings.buildName = "Release"; bIsDirty = true; CheckPaths(); });
                menu.AddItem(new GUIContent("Debug"), settings.buildName == "Debug", () => { settings.buildName = "Debug"; bIsDirty = true; CheckPaths(); });

                menu.DropDown(EditorGUILayoutEx.GetLastRect());
            }

            using (EditorGUIEx.DisabledScopeIf(!m_CanImport))
            {
                if (GUILayout.Button("Import"))
                {
                    foreach (string file in Directory.GetFiles(m_UnityEngineBuildPath))
                    {
                        if (file.EndsWith("dll") || file.EndsWith("pdb"))
                        {
                            string fileName = Path.GetFileName(file);
                            string destFile = Path.Combine(m_UnityEngineAssembliesPath, fileName);
                            if (File.GetLastWriteTime(file) != File.GetLastWriteTime(destFile))
                            {
                                File.Copy(file, destFile, true);
                                EditorProgressBar.ShowProgressBar("Importing {0}...".format(fileName), 1);
                            }
                        }
                    }

                    foreach (string file in Directory.GetFiles(m_UnityEditorBuildPath))
                    {
                        if (file.EndsWith("dll") || file.EndsWith("pdb"))
                        {
                            string fileName = Path.GetFileName(file);
                            string destFile = Path.Combine(m_UnityEditorAssembliesPath, fileName);
                            if (File.GetLastWriteTime(file) != File.GetLastWriteTime(destFile))
                            {
                                File.Copy(file, destFile, true);
                                EditorProgressBar.ShowProgressBar("Importing {0}...".format(fileName), 1);
                            }
                        }
                    }

                    EditorProgressBar.ClearProgressBar();
                    AssetDatabase.Refresh();
                }
            }

            if (bIsDirty)
            {
                InternalEditorUtility.SaveToSerializedFileAndForget(new UnityEngine.Object[1] {
                    settings
                }, m_SettingsPath, true);
            }
        }
Example #3
0
        void OnGUI()
        {
            if (scenes.Count == 0)
            {
                FindSceneInProject();
            }

            using (EditorGUILayoutEx.ScrollView(ref m_ScrollPosition))
            {
                List <string> lastFolders = new List <string>();

                bool bRefresh = false;
                foreach (string folder in scenes.Keys.OrderBy(s => s))
                {
                    if (!foldouts[folder])
                    {
                        lastFolders.Add(folder);
                        continue;
                    }

                    using (GUILayoutEx.Horizontal())
                    {
                        foldouts[folder] = EditorGUILayout.Foldout(foldouts[folder], "{0}:".format(folder) /*, EditorStyles.boldLabel*/);
                        if (!bRefresh && GUILayout.Button("Refresh", GUILayout.Width(80)))
                        {
                            scenes.Clear();
                            break;
                        }
                        bRefresh = true;
                    }

                    if (foldouts[folder])
                    {
                        foreach (string sceneName in scenes[folder])
                        {
                            using (GUILayoutEx.Horizontal())
                            {
                                if (GUILayout.Button(Path.GetFileName(sceneName), GUILayout.Height(20)))
                                {
                                    if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
                                    {
                                        EditorSceneManager.OpenScene(sceneName);
                                    }
                                }
                                if (GUILayout.Button(new GUIContent("S", "Show scene in project view."), GUILayout.Width(20)))
                                {
                                    EditorGUIUtility.PingObject(AssetDatabase.LoadMainAssetAtPath(sceneName));
                                }
                            }
                        }
                    }
                }

                foreach (string folder in lastFolders)
                {
                    using (GUILayoutEx.Horizontal())
                    {
                        foldouts[folder] = EditorGUILayout.Foldout(foldouts[folder], "{0}:".format(folder) /*, EditorStyles.boldLabel*/);
                        if (!bRefresh && GUILayout.Button("Refresh", GUILayout.Width(80)))
                        {
                            scenes.Clear();
                            break;
                        }
                        bRefresh = true;
                    }
                }
            }
        }