예제 #1
0
        private void OnGUI()
        {
            if (m_ActiveGameObjects == null || m_ActiveGameObjects.Length == 0 || m_ActiveGameObjects[0] == null)
            {
                return;
            }

            using (EditorGUILayoutEx.ScrollView(ref m_ScrollPosition))
            {
                foreach (var i in m_ActiveSpyglassEditors)
                {
                    using (GUILayoutEx.Vertical())
                    {
                        i.Item2 = EditorGUILayout.InspectorTitlebar(i.Item2, ((Editor)i.Item1).target);
                        if (i.Item2)
                        {
                            try
                            {
                                i.Item1.OnSpyglassGUI();
                            }
                            catch (Exception e)
                            {
                                if (GUIUtilityEx.ShouldRethrowException(e))
                                {
                                    throw;
                                }

                                Debug.LogException(e);
                            }
                        }
                    }
                }
            }
        }
예제 #2
0
        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)))
                            {
                            }
                        }
                    }
                }
            }
        }
예제 #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;
                    }
                }
            }
        }