From 39b0fb13462d5f06c36984ab852f42b696acd316 Mon Sep 17 00:00:00 2001 From: "instance.id" Date: Thu, 27 May 2021 18:25:59 -0500 Subject: [PATCH 1/3] Added left and right directional buttons --- .../Editor/GUI/ProjectBookmarkWindow.cs | 44 ++++++++++++++++--- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/Assets/AssetBookmarker/Editor/Project/Editor/GUI/ProjectBookmarkWindow.cs b/Assets/AssetBookmarker/Editor/Project/Editor/GUI/ProjectBookmarkWindow.cs index 27d13a3..d172654 100644 --- a/Assets/AssetBookmarker/Editor/Project/Editor/GUI/ProjectBookmarkWindow.cs +++ b/Assets/AssetBookmarker/Editor/Project/Editor/GUI/ProjectBookmarkWindow.cs @@ -19,7 +19,12 @@ public class ProjectBookmarkWindow : BookmarkWindowBase /// Label領域の大きさ /// private const float LabelWidth = 68f; - + + /// + /// Directional button size + /// + private const float DirButtonWidth = 16f; + /// /// ボタンの大きさ /// @@ -44,7 +49,7 @@ public class ProjectBookmarkWindow : BookmarkWindowBase /// 現在選択しているブックマークデータ名 /// [SerializeField] private string currentBookmarkName; - + /// /// ブックマーク情報 /// @@ -54,9 +59,12 @@ public class ProjectBookmarkWindow : BookmarkWindowBase private static bool needReloadData = false; private static Object[] willRegisterAssets = null; + private static GUIContent prevIcon; + private static GUIContent nextIcon; + /// /// アセットのロード時に呼ばれる - /// + /// [DidReloadScripts] [InitializeOnLoadMethodAttribute] public static void OnLoadAssets() @@ -89,20 +97,42 @@ private void OnGUI() { this.RebuildBookmarkList(); } - + if (willRegisterAssets != null) { - var data = this.bookmarkDatas[this.currentBookmarkIndex]; + var data = this.bookmarkDatas[this.currentBookmarkIndex]; data.Assets.AddRange(willRegisterAssets); EditorUtility.SetDirty(data); willRegisterAssets = null; } + prevIcon ??= EditorGUIUtility.IconContent("d_Profiler.PrevFrame"); + nextIcon ??= EditorGUIUtility.IconContent("d_Profiler.NextFrame"); + EditorGUILayout.LabelField(MenuConfig.GUI_WINDOW_PROJECT_TEXT_OVERVIEW); EditorGUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); EditorGUILayout.LabelField("Bookmark", GUILayout.Width(LabelWidth)); - int index = EditorGUILayout.Popup(this.currentBookmarkIndex, this.popupDisplayedOptions); + + int dirIndex = currentBookmarkIndex; + + EditorGUIUtility.SetIconSize(new Vector2(14, 14)); + if (GUILayout.Button(prevIcon, EditorStyles.miniButton, GUILayout.Width(DirButtonWidth))) + { + if (dirIndex > 0) --dirIndex; + } + + int index = EditorGUILayout.Popup(currentBookmarkIndex, popupDisplayedOptions); + + EditorGUIUtility.SetIconSize(new Vector2(14, 14)); + if (GUILayout.Button(nextIcon, EditorStyles.miniButton, GUILayout.Width(DirButtonWidth))) + { + if (dirIndex < bookmarkDatas.Length - 1) ++dirIndex; + } + + if (index != currentBookmarkIndex) { } + else index = dirIndex; + if (EditorGUI.EndChangeCheck()) { if (index < bookmarkDatas.Length) @@ -255,7 +285,7 @@ static private void DoRemoveButton(ReorderableList list, int index) window.Repaint(); }; } - + /// /// ウィンドウを開く /// From becc9826f8f41fd295c8daba415fd3809533a843 Mon Sep 17 00:00:00 2001 From: "instance.id" <48368821+instance-id@users.noreply.github.com> Date: Sat, 14 Jan 2023 22:36:13 -0600 Subject: [PATCH 2/3] Update Assets/AssetBookmarker/Editor/Project/Editor/GUI/ProjectBookmarkWindow.cs Co-authored-by: WaterBeary <103973703+CuteWaterBeary@users.noreply.github.com> --- .../Editor/Project/Editor/GUI/ProjectBookmarkWindow.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/AssetBookmarker/Editor/Project/Editor/GUI/ProjectBookmarkWindow.cs b/Assets/AssetBookmarker/Editor/Project/Editor/GUI/ProjectBookmarkWindow.cs index d172654..867712b 100644 --- a/Assets/AssetBookmarker/Editor/Project/Editor/GUI/ProjectBookmarkWindow.cs +++ b/Assets/AssetBookmarker/Editor/Project/Editor/GUI/ProjectBookmarkWindow.cs @@ -107,7 +107,7 @@ private void OnGUI() } prevIcon ??= EditorGUIUtility.IconContent("d_Profiler.PrevFrame"); - nextIcon ??= EditorGUIUtility.IconContent("d_Profiler.NextFrame"); + nextIcon = EditorGUIUtility.IconContent("d_Profiler.NextFrame"); EditorGUILayout.LabelField(MenuConfig.GUI_WINDOW_PROJECT_TEXT_OVERVIEW); EditorGUILayout.BeginHorizontal(); From b169fd5773cd57a836ff450c2311cc2ad092cc7e Mon Sep 17 00:00:00 2001 From: "instance.id" <48368821+instance-id@users.noreply.github.com> Date: Sat, 14 Jan 2023 22:49:54 -0600 Subject: [PATCH 3/3] Remove null coalescing --- .../Editor/Project/Editor/GUI/ProjectBookmarkWindow.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/AssetBookmarker/Editor/Project/Editor/GUI/ProjectBookmarkWindow.cs b/Assets/AssetBookmarker/Editor/Project/Editor/GUI/ProjectBookmarkWindow.cs index 867712b..5815471 100644 --- a/Assets/AssetBookmarker/Editor/Project/Editor/GUI/ProjectBookmarkWindow.cs +++ b/Assets/AssetBookmarker/Editor/Project/Editor/GUI/ProjectBookmarkWindow.cs @@ -106,7 +106,7 @@ private void OnGUI() willRegisterAssets = null; } - prevIcon ??= EditorGUIUtility.IconContent("d_Profiler.PrevFrame"); + prevIcon = EditorGUIUtility.IconContent("d_Profiler.PrevFrame"); nextIcon = EditorGUIUtility.IconContent("d_Profiler.NextFrame"); EditorGUILayout.LabelField(MenuConfig.GUI_WINDOW_PROJECT_TEXT_OVERVIEW);