Ejemplo n.º 1
0
        internal static void Init()
        {
            _window = GetWindow <ShowRecentScenes>();
            _window.titleContent.text    = RECENT;
            _window.titleContent.tooltip = RECENTTOOLTIP;

            _window.titleContent.image = ToolIconSmall;


            _window.minSize = WindowMin;
            _window.Show();
        }
Ejemplo n.º 2
0
 private static void OpenRecentScenes()
 {
     ShowRecentScenes.Init();
 }
Ejemplo n.º 3
0
        private void OnGUI()
        {
            if (_window == null)
            {
                _window = this;

                _window.titleContent.image = ToolIcon;
            }

            EditorGUILayout.BeginVertical(BOX);

            GUILayout.Space(2);

            #region Help Button

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.Space();

            if (_helpBttn == null)
            {
                _helpBttn = EditorGUIUtility.Load(HELPICON) as Texture2D;
            }

            var helpStyle = new GUIStyle(GUIStyle.none)
            {
                fontStyle = FontStyle.Bold
            };
            var helpContent = new GUIContent(string.Empty, _helpBttn, HELPTOOLTIP);

            if (GUILayout.Button(helpContent, helpStyle, GUILayout.Width(15)))
            {
                if (_infoWindow == null)
                {
                    _infoWindow = InfoWindow.InfoInit();
                }
            }

            GUILayout.Space(3);
            EditorGUILayout.EndHorizontal();

            #endregion

            GUILayout.Space(1);

            #region Fav or Recent Tab

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.Space();
            var tabSkin = new GUIStyle(GUI.skin.button)
            {
                alignment = TextAnchor.MiddleCenter,
                fontSize  = 12,
                fontStyle = FontStyle.Bold
            };

            var recentBttn   = new GUIContent(RECENT, RECENTBUTTONTOOLTIP);
            var favoriteBttn = new GUIContent(FAVORITES, FAVORITESBUTTONTOOLTIP);
            RecentSceneManager.recentOrFav = GUILayout.SelectionGrid(RecentSceneManager.recentOrFav,
                                                                     new[] { recentBttn, favoriteBttn }, 2, tabSkin, GUILayout.MaxWidth(200));
            EditorGUILayout.Space();
            EditorGUILayout.EndHorizontal();

            #endregion

            GUILayout.Label("", GUI.skin.horizontalSlider);

            _scrollPos = GUILayout.BeginScrollView(_scrollPos);
            if (RecentSceneManager.recentOrFav == 0)
            {
                var labelWidth = 0f;
                foreach (var scene in RecentSceneManager.recentScenes)
                {
                    var textDimensions = GUI.skin.label.CalcSize(new GUIContent(scene));
                    if (textDimensions.x > labelWidth)
                    {
                        labelWidth = textDimensions.x;
                    }
                }

                for (var i = 0; i < RecentSceneManager.recentScenes.Count; i++)
                {
                    i = DisplayObject(i, RecentSceneManager.recentScenes);
                }

                if (RecentSceneManager.recentScenes.Count > 0)
                {
                    var spaceSize = RecentSceneManager.keepTrackOfRecentScenes + 1 -
                                    RecentSceneManager.recentScenes.Count;
                    spaceSize *= 28;
                    GUILayout.Space(pixels: spaceSize);

                    EditorGUILayout.EndScrollView();
                    if (GUILayout.Button(CLEARRECENT))
                    {
                        for (var j = 0; j < RecentSceneManager.recentScenes.Count; j++)
                        {
                            RecentSceneManager.recentScenes[j] = null;
                            InitializeSceneManager.RemoveKey(Application.productName + RECENTSCENES + j);
                        }
                    }
                }
                else
                {
                    EditorGUILayout.EndScrollView();
                    GUILayout.Space(20);
                    var centerBoldLabel = new GUIStyle(EditorStyles.label)
                    {
                        alignment = TextAnchor.MiddleCenter,
                        fontStyle = FontStyle.Bold
                    };
                    GUILayout.Label(NORECENT, centerBoldLabel);
                    GUILayout.Space(130);

                    if (GUILayout.Button(RecentSceneManager.CLOSE))
                    {
                        _window.Close();
                    }
                }
            }
            else
            {
                var labelWidth = 0f;
                foreach (var scene in FavoriteScenesManager.favoritedScenes)
                {
                    var textDimensions = GUI.skin.label.CalcSize(new GUIContent(scene));
                    if (textDimensions.x > labelWidth)
                    {
                        labelWidth = textDimensions.x;
                    }
                }

                for (var i = 0; i < FavoriteScenesManager.favoritedScenes.Count; i++)
                {
                    i = DisplayObject(i, FavoriteScenesManager.favoritedScenes);
                }

                if (FavoriteScenesManager.favoritedScenes.Count > 0)
                {
                    var spaceSize = RecentSceneManager.keepTrackOfRecentScenes + 1 -
                                    RecentSceneManager.recentScenes.Count;
                    spaceSize *= 28;
                    GUILayout.Space(pixels: spaceSize);

                    EditorGUILayout.EndScrollView();
                    var clearFavBttn = new GUIContent(CLEARFAVORITES, CLEARFAVTOOLTIP);
                    if (GUILayout.Button(clearFavBttn))
                    {
                        if (EditorUtility.DisplayDialog(CLEARFAVCONFIRM, CLEARFAVMSG,
                                                        RecentSceneManager.YES, RecentSceneManager.NO))
                        {
                            for (var j = 0; j < FavoriteScenesManager.favoritedScenes.Count; j++)
                            {
                                FavoriteScenesManager.favoritedScenes[j] = null;
                                InitializeSceneManager.RemoveKey(Application.productName + FAVORITESCENES + j);
                            }

                            FavoriteScenesManager.favoritedScenes.Clear();
                        }
                    }
                }
                else
                {
                    EditorGUILayout.EndScrollView();
                    GUILayout.Space(20);
                    var centerBoldLabel = new GUIStyle(EditorStyles.label)
                    {
                        alignment = TextAnchor.MiddleCenter,
                        fontStyle = FontStyle.Bold
                    };
                    GUILayout.Label(NOFAVORITES, centerBoldLabel);
                    GUILayout.Space(130);

                    if (GUILayout.Button(RecentSceneManager.CLOSE))
                    {
                        _window.Close();
                    }
                }
            }

            EditorGUILayout.EndVertical();
        }