Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: antonysze/unity-custom-play-button
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.0
Choose a base ref
...
head repository: antonysze/unity-custom-play-button
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
  • 11 commits
  • 9 files changed
  • 1 contributor

Commits on Jan 6, 2022

  1. Update README.md

    antonysze authored Jan 6, 2022
    Copy the full SHA
    ed4424c View commit details
  2. Update README.md

    antonysze authored Jan 6, 2022
    Copy the full SHA
    4e382b3 View commit details
  3. Update README.md

    antonysze authored Jan 6, 2022
    Copy the full SHA
    2c00c2f View commit details
  4. Update README.md

    antonysze authored Jan 6, 2022
    Copy the full SHA
    adb4f8f View commit details
  5. Update README.md

    antonysze authored Jan 6, 2022
    Copy the full SHA
    f93391b View commit details

Commits on Apr 28, 2023

  1. Update README.md

    antonysze authored Apr 28, 2023
    Copy the full SHA
    b6d122e View commit details

Commits on Jun 23, 2025

  1. Copy the full SHA
    1522230 View commit details
  2. Update README.md

    antonysze authored Jun 23, 2025
    Copy the full SHA
    8f9151b View commit details

Commits on Jul 30, 2025

  1. Update .gitignore

    antonysze committed Jul 30, 2025
    Copy the full SHA
    cdb0ae2 View commit details
  2. Update to 1.2.0

    - Support older version instead of only Unity 6
    - Add popup width to settings
    antonysze committed Jul 30, 2025
    Copy the full SHA
    27a0853 View commit details
  3. Update to 1.2.0

     - Support older version instead of only Unity 6
    - Add popup width to settings
    antonysze committed Jul 30, 2025
    Copy the full SHA
    ff2dc1a View commit details
Showing with 383 additions and 95 deletions.
  1. +2 −1 .gitignore
  2. +11 −0 CHANGELOG.md
  3. +1 −26 Editor/CustomPlayButton.cs
  4. +73 −53 Editor/EditorSelectScenePopup.cs
  5. +134 −6 Editor/SceneBookmark.cs
  6. +148 −0 Editor/SceneListSettingsProvider.cs
  7. +2 −0 Editor/SceneListSettingsProvider.cs.meta
  8. +11 −8 README.md
  9. +1 −1 package.json
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -19,8 +19,9 @@
# Autogenerated Jetbrains Rider plugin
[Aa]ssets/Plugins/Editor/JetBrains*

# Visual Studio cache directory
# IDE cache directory
.vs/
.idea/

# Gradle cache directory
.gradle/
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.2.0] - 2025-06-22
### Changed
- Support older version instead of only Unity 6
- Add popup width to settings

## [1.1.0] - 2025-06-22
### Changed
- Use editor preference setting to store bookmarks instead of ScriptableObject
- Swap bookmark and scene button to make it more intuitive
- Now can only support Unity 6 since `SettingsProvider` starts being used

## [1.0.0] - 2022-01-05
### Added
- First version of the package
27 changes: 1 addition & 26 deletions Editor/CustomPlayButton.cs
Original file line number Diff line number Diff line change
@@ -24,10 +24,8 @@ public static class CustomPlayButton
{
#if UNITY_TOOLBAR_EXTENDER
const string FOLDER_PATH = "Assets/Editor/CustomPlayButton/";
const string SETTING_PATH = FOLDER_PATH + "BookmarkSetting.asset";
const string ICONS_PATH = "Packages/com.antonysze.custom-play-button/Editor/Icons/";

private static SceneBookmark bookmark = null;
private static SceneAsset selectedScene = null;


@@ -38,22 +36,6 @@ public static class CustomPlayButton
static VisualElement toolbarElement;
static SceneAsset lastScene = null;

public static SceneBookmark Bookmark
{
get
{
if (bookmark == null)
{
bookmark = ScriptableObject.CreateInstance<SceneBookmark>();
if (!Directory.Exists(FOLDER_PATH))
Directory.CreateDirectory(FOLDER_PATH);
AssetDatabase.CreateAsset(bookmark, SETTING_PATH);
AssetDatabase.Refresh();
}
return bookmark;
}
}

public static SceneAsset SelectedScene
{
get { return selectedScene; }
@@ -96,12 +78,6 @@ static CustomPlayButton()
ToolbarExtender.LeftToolbarGUI.Add(OnToolbarLeftGUI);
EditorApplication.update += OnUpdate;

if (bookmark == null)
{
bookmark = AssetDatabase.LoadAssetAtPath<SceneBookmark>(SETTING_PATH);
Bookmark?.RemoveNullValue();
}

var savedScenePath = EditorPrefs.GetString(GetEditorPrefKey(), "");
selectedScene = AssetDatabase.LoadAssetAtPath<SceneAsset>(savedScenePath);
if (selectedScene == null && EditorBuildSettings.scenes.Length > 0)
@@ -120,6 +96,7 @@ static void OnToolbarLeftGUI()

var sceneName = selectedScene != null ? selectedScene.name : "Select Scene...";
var selected = EditorGUILayout.DropdownButton(new GUIContent(sceneName), FocusType.Passive, GUILayout.Width(128.0f));

if (Event.current.type == EventType.Repaint)
{
buttonRect = GUILayoutUtility.GetLastRect();
@@ -162,8 +139,6 @@ static void OnToolbarLeftGUI()
{
EditorWindow.GetWindow(System.Type.GetType("UnityEditor.BuildPlayerWindow,UnityEditor"));
}
// Avoid error from GUILayout.EndHorizontal()
GUILayout.BeginHorizontal();
}
}
}
126 changes: 73 additions & 53 deletions Editor/EditorSelectScenePopup.cs
Original file line number Diff line number Diff line change
@@ -8,9 +8,11 @@ namespace ASze.CustomPlayButton
{
public class EditorSelectScenePopup : PopupWindowContent
{
const float COLLUMN_WIDTH = 200.0f;
public const string EDITOR_COLUMN_WIDTH_PREF_KEY = "ASze.CustomPlayButton.columnWidth";
private const float DEFAULT_COLUMN_WIDTH = 200.0f;
const float ICON_SIZE = 20.0f;
readonly GUILayoutOption[] ICON_LAYOUT = new GUILayoutOption[] {
GUILayout.Width(20.0f), GUILayout.Height(20.0f)
GUILayout.Width(ICON_SIZE), GUILayout.Height(ICON_SIZE)
};


@@ -24,6 +26,8 @@ public class EditorSelectScenePopup : PopupWindowContent
Vector2 scrollPosBuild;
Vector2 scrollPosBookmark;

private float collumnWidth;

public EditorSelectScenePopup() : base()
{
InitStyles();
@@ -32,7 +36,8 @@ public EditorSelectScenePopup() : base()

GetBuildScenes();
currentScene = AssetDatabase.LoadAssetAtPath<SceneAsset>(EditorSceneManager.GetActiveScene().path);
CustomPlayButton.Bookmark.RemoveNullValue();


}

void InitStyles()
@@ -71,20 +76,12 @@ public static Texture2D MakeTex(Color col)

public override Vector2 GetWindowSize()
{
var width = COLLUMN_WIDTH * (CustomPlayButton.Bookmark.HasBookmark() ? 2 : 1);
var maxRow = Mathf.Max(buildScenes.Length, CustomPlayButton.Bookmark.bookmarks.Count, 1);
var width = GetColumnWidth() * (SceneBookmark.HasBookmark() ? 2 : 1);
var maxRow = Mathf.Max(buildScenes.Length, SceneBookmark.Bookmarks.Count, 1);
var height = Mathf.Min(22 * maxRow + 26, Screen.currentResolution.height * 0.5f);
return new Vector2(width, height);
}

public override void OnClose()
{
if (EditorUtility.IsDirty(CustomPlayButton.Bookmark))
{
AssetDatabase.SaveAssets();
}
}

public override void OnGUI(Rect rect)
{
EditorGUILayout.BeginHorizontal();
@@ -102,14 +99,15 @@ void DrawBuildScenes()

EditorGUILayout.BeginHorizontal();
GUILayout.Label("Scenes in Build", EditorStyles.boldLabel, GUILayout.Height(20.0f));
if (!CustomPlayButton.Bookmark.HasBookmark())
#if UNITY_6000_0_OR_NEWER
if (!SceneBookmark.HasBookmark())
{
GUILayout.FlexibleSpace();
if (GUILayout.Button(bookmarkContent, buttonStyle, ICON_LAYOUT))
if (GUILayout.Button(EditorGUIUtility.IconContent("blendKeySelected"), titleButtonStyle, ICON_LAYOUT))
{
Selection.activeObject = CustomPlayButton.Bookmark;
SceneListSettingsProvider.OpenBookmarkSettings();
}
}
#endif
EditorGUILayout.EndHorizontal();

if (buildScenes.Length > 0)
@@ -130,90 +128,102 @@ void DrawBuildScenes()

void DrawBookmarkScenes()
{
var bookmarkSetting = CustomPlayButton.Bookmark;
if (!bookmarkSetting.HasBookmark()) return;
if (!SceneBookmark.HasBookmark()) return;

EditorGUILayout.BeginVertical(GUILayout.MinWidth(COLLUMN_WIDTH));
EditorGUILayout.BeginVertical(GUILayout.MinWidth(GetColumnWidth()));

#if UNITY_6000_0_OR_NEWER
var content = new GUIContent(bookmarkContent);
content.text = "Bookmark";
content.text = " Bookmarks";
if (GUILayout.Button(content, titleButtonStyle, GUILayout.Height(20.0f)))
{
Selection.activeObject = CustomPlayButton.Bookmark;
SceneListSettingsProvider.OpenBookmarkSettings();
}

#endif

scrollPosBookmark = EditorGUILayout.BeginScrollView(scrollPosBookmark);
var bookmarks = new List<SceneAsset>(bookmarkSetting.bookmarks);
foreach (var bookmark in bookmarks)
var bookmarks = new List<SceneAsset>(SceneBookmark.Bookmarks);
for (int i = 0; i < bookmarks.Count; i++)
{
DrawSelection(bookmark);
DrawSelection(bookmarks[i], i);
}

EditorGUILayout.EndScrollView();
EditorGUILayout.EndVertical();
}

void DrawSelection(SceneAsset scene, int index = -1, bool bookmarkButton = false)
{
if (scene == null) return;

GUILayout.BeginHorizontal();
var style = CustomPlayButton.SelectedScene == scene ? selectedButtonStyle : buttonStyle;
if (GUILayout.Button(index >= 0 ? $"{index}\t{scene.name}" : scene.name, style))
string sceneName = scene != null ? scene.name : "<NOT FOUND>";
if (GUILayout.Button(index >= 0 ? $"{index}\t{sceneName}" : sceneName, style))
{
SelectScene(scene);
}

if (scene != null)
{
style = currentScene == scene ? selectedButtonStyle : buttonStyle;
if (GUILayout.Button(EditorGUIUtility.IconContent("d_BuildSettings.SelectedIcon", "Open Scene"), style, ICON_LAYOUT))
{
OpenScene(scene);
}
}
else
{
GUILayout.Space(ICON_SIZE);
}


if (bookmarkButton)
{
var bookmarks = CustomPlayButton.Bookmark.bookmarks;
var inBookmark = bookmarks.Contains(scene);
GUIContent content;
if (inBookmark)
content = EditorGUIUtility.IconContent("blendKeySelected", "Unbookmark");
else
content = EditorGUIUtility.IconContent("blendKeyOverlay", "Bookmark");
if (GUILayout.Button(content, buttonStyle, ICON_LAYOUT))
if (scene != null)
{
bool inBookmark = SceneBookmark.Bookmarks.Contains(scene);
GUIContent content;
if (inBookmark)
{
bookmarks.Remove(scene);
}
content = EditorGUIUtility.IconContent("blendKeySelected", "Unbookmark");
else
content = EditorGUIUtility.IconContent("blendKeyOverlay", "Bookmark");
if (GUILayout.Button(content, buttonStyle, ICON_LAYOUT))
{
bookmarks.Add(scene);
if (inBookmark)
{
SceneBookmark.RemoveBookmark(scene);
}
else
{
SceneBookmark.AddBookmark(scene);
}
}
bookmarks.RemoveAll(item => item == null);
EditorUtility.SetDirty(CustomPlayButton.Bookmark);
}
else
{
GUILayout.Space(ICON_SIZE);
}
}
else
{
if (GUILayout.Button(EditorGUIUtility.IconContent("d_winbtn_win_close", "Unbookmark"), buttonStyle, ICON_LAYOUT))
if (GUILayout.Button(EditorGUIUtility.IconContent("d_P4_DeletedLocal", "Unbookmark"), buttonStyle, ICON_LAYOUT))
{
var bookmarks = CustomPlayButton.Bookmark.bookmarks;
bookmarks.Remove(scene);
bookmarks.RemoveAll(item => item == null);
EditorUtility.SetDirty(CustomPlayButton.Bookmark);
SceneBookmark.RemoveBookmarkAt(index);
}
}

style = currentScene == scene ? selectedButtonStyle : buttonStyle;
if (GUILayout.Button(EditorGUIUtility.IconContent("d_BuildSettings.SelectedIcon", "Open Scene"), style, ICON_LAYOUT))
{
OpenScene(scene);
}
GUILayout.EndHorizontal();
}

void SelectScene(SceneAsset scene)
{
if (scene == null) return;
CustomPlayButton.SelectedScene = scene;
editorWindow.Close();
}

void OpenScene(SceneAsset scene)
{
if (scene == null) return;
if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
{
var scenePath = AssetDatabase.GetAssetPath(scene);
@@ -236,6 +246,16 @@ void GetBuildScenes()
}
buildScenes = buildSceneList.ToArray();
}

public static float GetColumnWidth()
{
return EditorPrefs.GetFloat(EDITOR_COLUMN_WIDTH_PREF_KEY, DEFAULT_COLUMN_WIDTH);
}

public static void SaveColumnWidth(float columnWidth)
{
EditorPrefs.SetFloat(EDITOR_COLUMN_WIDTH_PREF_KEY, columnWidth);
}
}
}
#endif
Loading