1.8.2: Changed icon on scene loading toggle and added a create new scene button
This commit is contained in:
parent
38e771c549
commit
de2745d68a
11
CHANGELOG.md
11
CHANGELOG.md
|
|
@ -1,7 +1,16 @@
|
|||
# Change Log
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## [1.8.0] - 2022-12-07
|
||||
## [1.8.2] - 2023-03-14
|
||||
|
||||
### Added
|
||||
- Create new scene next to scene picker
|
||||
|
||||
### Changed
|
||||
- Icon on additive and single scene toggle changed to be single or multiple "window" icon
|
||||
|
||||
|
||||
## [1.8.1] - 2022-12-07
|
||||
|
||||
### Changed
|
||||
- Updated README.md to include all default tools
|
||||
|
|
|
|||
26
Editor/Toolbar/Tools/Settings/ToolbarProjectSettings.cs
Normal file
26
Editor/Toolbar/Tools/Settings/ToolbarProjectSettings.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
using UnityEditor;
|
||||
|
||||
namespace Module.NavigationTool.Editor.Toolbar
|
||||
{
|
||||
internal sealed class ToolbarProjectSettings : IToolbarSettings
|
||||
{
|
||||
public string Title => "Project";
|
||||
|
||||
private const string PREF_PROJECT_SAVE_ENABLED = "ToolbarSettings.IsProjectSaveEnabled";
|
||||
|
||||
public static bool IsProjectSaveEnabled
|
||||
{
|
||||
get => EditorPrefs.GetBool(PREF_PROJECT_SAVE_ENABLED, false);
|
||||
set => EditorPrefs.SetBool(PREF_PROJECT_SAVE_ENABLED, value);
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
IsProjectSaveEnabled = EditorGUILayout.Toggle("Enable Save button", IsProjectSaveEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0442ccbddf87428b85f2d98cfa033ca5
|
||||
timeCreated: 1670955254
|
||||
32
Editor/Toolbar/Tools/ToolProjectSave.cs
Normal file
32
Editor/Toolbar/Tools/ToolProjectSave.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
using JetBrains.Annotations;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UTools = UnityEditor.Tools;
|
||||
|
||||
namespace Module.NavigationTool.Editor.Toolbar
|
||||
{
|
||||
[UsedImplicitly]
|
||||
internal sealed class ToolProjectSave : AbstractToolbarDrawer
|
||||
{
|
||||
public override bool Visible => ToolbarProjectSettings.IsProjectSaveEnabled;
|
||||
public override bool Enabled => true;
|
||||
public override EToolbarPlacement Placement => EToolbarPlacement.Right;
|
||||
public override int Priority => (int)EToolbarPriority.Low;
|
||||
|
||||
private static readonly GUIContent LABEL = new GUIContent(string.Empty, "Deletes all PlayerPrefs entries");
|
||||
|
||||
protected override void Draw(Rect rect)
|
||||
{
|
||||
bool isButtonPressed = GUI.Button(rect, styles.iconProject, styles.button);
|
||||
GUI.Label(rect, LABEL, styles.labelCenter);
|
||||
|
||||
if (isButtonPressed)
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
|
||||
public override float CalculateWidth()
|
||||
{
|
||||
return 24.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Editor/Toolbar/Tools/ToolProjectSave.cs.meta
Normal file
3
Editor/Toolbar/Tools/ToolProjectSave.cs.meta
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 97a541d20e644506b1fe20e85e561642
|
||||
timeCreated: 1670955217
|
||||
|
|
@ -24,8 +24,10 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
private static string[] SCENE_NAMES = new string[0];
|
||||
private static string[] SCENE_SHORT_NAMES = new string[0];
|
||||
private static string[] SCENE_PATHS = new string[0];
|
||||
private static readonly GUIContent LABEL_ADDITIVE = new GUIContent(string.Empty, "Toggles between Single and Additive scene loading");
|
||||
|
||||
private static readonly GUIContent LABEL_SCENE_ADDITIVE = new GUIContent(string.Empty, "Additive scene loading (toogle to Single)");
|
||||
private static readonly GUIContent LABEL_SCENE_SINGLE = new GUIContent(string.Empty, "Single scene loading (toggle to Additive)");
|
||||
private static readonly GUIContent LABEL_SCENE_CREATE = new GUIContent(string.Empty, "Create a new scene");
|
||||
private const float BUTTON_WIDTH = 24.0f;
|
||||
|
||||
private static bool IS_DIRTY = true;
|
||||
|
||||
|
|
@ -142,19 +144,55 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
protected override void Draw(Rect rect)
|
||||
{
|
||||
Initialize();
|
||||
var rect0 = new Rect(rect.x, rect.y, rect.width - 24.0f, rect.height);
|
||||
var rect1 = new Rect(rect0.xMax, rect.y, 24.0f, rect.height);
|
||||
|
||||
if (GUI.Button(rect0, SCENE_LABEL, styles.popup))
|
||||
ShowDropDown(rect0);
|
||||
var rect0 = new Rect(rect.x, rect.y, rect.width - BUTTON_WIDTH * 2.0f, rect.height);
|
||||
var rect1 = new Rect(rect0.xMax, rect.y, BUTTON_WIDTH, rect.height);
|
||||
var rect2 = new Rect(rect1.xMax, rect.y, BUTTON_WIDTH, rect.height);
|
||||
DrawSceneDropDown(rect0);
|
||||
DrawSceneLoadToggle(rect1);
|
||||
DrawSceneAddButton(rect2);
|
||||
}
|
||||
|
||||
private void DrawSceneDropDown(Rect rect)
|
||||
{
|
||||
if (GUI.Button(rect, SCENE_LABEL, styles.popup))
|
||||
ShowDropDown(rect);
|
||||
}
|
||||
|
||||
private void DrawSceneLoadToggle(Rect rect)
|
||||
{
|
||||
bool isScenePickerSetAsAdditive = ToolbarScenePickerSettings.IsScenePickerSetAsAdditive;
|
||||
bool temp = EditorGUI.Toggle(rect1, isScenePickerSetAsAdditive, styles.button);
|
||||
GUI.Label(rect1, temp ? styles.iconPlusSmall : styles.iconPlusTiny, styles.labelCenter);
|
||||
GUI.Label(rect1, LABEL_ADDITIVE, styles.labelCenter);
|
||||
bool tempIsAdditive = EditorGUI.Toggle(rect, isScenePickerSetAsAdditive, styles.button);
|
||||
|
||||
if (temp != isScenePickerSetAsAdditive)
|
||||
ToolbarScenePickerSettings.IsScenePickerSetAsAdditive = temp;
|
||||
if (tempIsAdditive)
|
||||
{
|
||||
GUI.Label(rect, styles.iconSceneAdditive, styles.labelCenter);
|
||||
GUI.Label(rect, LABEL_SCENE_ADDITIVE, styles.labelCenter);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUI.Label(rect, styles.iconSceneSingle, styles.labelCenter);
|
||||
GUI.Label(rect, LABEL_SCENE_SINGLE, styles.labelCenter);
|
||||
}
|
||||
|
||||
if (tempIsAdditive != isScenePickerSetAsAdditive)
|
||||
ToolbarScenePickerSettings.IsScenePickerSetAsAdditive = tempIsAdditive;
|
||||
}
|
||||
|
||||
private void DrawSceneAddButton(Rect rect)
|
||||
{
|
||||
if (GUI.Button(rect, styles.iconPlusSmall, styles.button))
|
||||
{
|
||||
if (!EditorUtility.DisplayDialog("Create new scene", "Are you sure that you want to create a new scene?", "Yes", "No"))
|
||||
return;
|
||||
|
||||
Scene scene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Additive);
|
||||
|
||||
if (EditorUtility.DisplayDialog("Create new scene", "Save scene to disk?", "Yes", "No"))
|
||||
EditorSceneManager.SaveScene(scene);
|
||||
}
|
||||
|
||||
GUI.Label(rect, LABEL_SCENE_CREATE, styles.labelCenter);
|
||||
}
|
||||
|
||||
private static void ShowDropDown(Rect rect)
|
||||
|
|
@ -216,7 +254,7 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
|
||||
public override float CalculateWidth()
|
||||
{
|
||||
return 124.0f;
|
||||
return 100.0f + BUTTON_WIDTH * 2.0f;
|
||||
}
|
||||
|
||||
public static void SetAsDirty()
|
||||
|
|
|
|||
|
|
@ -15,8 +15,10 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
public GUIStyle centeredMiniLabel;
|
||||
|
||||
public GUIContent iconPlusSmall;
|
||||
public GUIContent iconPlusTiny;
|
||||
public GUIContent iconSceneAdditive;
|
||||
public GUIContent iconSceneSingle;
|
||||
public GUIContent iconDisconnect;
|
||||
public GUIContent iconProject;
|
||||
|
||||
private GUISkin skin;
|
||||
|
||||
|
|
@ -57,8 +59,10 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
};
|
||||
|
||||
iconPlusSmall = EditorGUIUtility.IconContent("d_CreateAddNew");
|
||||
iconPlusTiny = EditorGUIUtility.IconContent("Toolbar Plus");
|
||||
iconSceneAdditive = EditorGUIUtility.IconContent("d_winbtn_win_restore_h");
|
||||
iconSceneSingle = EditorGUIUtility.IconContent("d_winbtn_win_max_h");
|
||||
iconDisconnect = EditorGUIUtility.IconContent("d_CacheServerDisconnected");
|
||||
iconProject = EditorGUIUtility.IconContent("Project");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "com.module.navigationtool",
|
||||
"version": "1.8.1",
|
||||
"version": "1.8.2",
|
||||
"displayName": "Module.NavigationTool",
|
||||
"description": "Support for navigation tools, like favorites, history and toolbars",
|
||||
"unity": "2019.2",
|
||||
|
|
|
|||
Loading…
Reference in a new issue