Project: Added button to open preferences and project settings
This commit is contained in:
parent
5e0634e069
commit
41604b98e7
|
|
@ -2,11 +2,12 @@
|
|||
|
||||
namespace Module.NavigationTool.Editor.Toolbar
|
||||
{
|
||||
internal sealed class ToolbarProjectSettings : IToolbarSettings
|
||||
internal sealed class ToolbarUnitySettings : IToolbarSettings
|
||||
{
|
||||
public string Title => "Project";
|
||||
public string Title => "Unity Project";
|
||||
|
||||
private const string PREF_PROJECT_SAVE_ENABLED = "ToolbarSettings.IsProjectSaveEnabled";
|
||||
private const string PREF_PROJECT_SETTINGS_ENABLED = "ToolbarSettings.IsProjectSettingsEnabled";
|
||||
|
||||
public static bool IsProjectSaveEnabled
|
||||
{
|
||||
|
|
@ -14,6 +15,12 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
set => EditorPrefs.SetBool(PREF_PROJECT_SAVE_ENABLED, value);
|
||||
}
|
||||
|
||||
public static bool IsProjectSettingsEnabled
|
||||
{
|
||||
get => EditorPrefs.GetBool(PREF_PROJECT_SETTINGS_ENABLED, false);
|
||||
set => EditorPrefs.SetBool(PREF_PROJECT_SETTINGS_ENABLED, value);
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
}
|
||||
|
|
@ -21,6 +28,7 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
public void Draw()
|
||||
{
|
||||
IsProjectSaveEnabled = EditorGUILayout.Toggle("Enable Save button", IsProjectSaveEnabled);
|
||||
IsProjectSettingsEnabled = EditorGUILayout.Toggle("Enable Project Settings button", IsProjectSettingsEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
39
Editor/Toolbar/Tools/ToolUnityProjectOpenSettings.cs
Normal file
39
Editor/Toolbar/Tools/ToolUnityProjectOpenSettings.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
using JetBrains.Annotations;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UTools = UnityEditor.Tools;
|
||||
|
||||
namespace Module.NavigationTool.Editor.Toolbar
|
||||
{
|
||||
[UsedImplicitly]
|
||||
internal sealed class ToolUnityProjectOpenSettings : AbstractToolbarDrawer
|
||||
{
|
||||
public override bool Visible => ToolbarUnitySettings.IsProjectSettingsEnabled;
|
||||
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, "Opens Preferences/Project Settings");
|
||||
private static readonly string[] OPTIONS = { "Preferences", "Project Settings" };
|
||||
|
||||
protected override void Draw(Rect rect)
|
||||
{
|
||||
int temp = EditorGUI.Popup(rect, -1, OPTIONS, styles.popup);
|
||||
GUI.Label(rect, styles.iconSettings, styles.button);
|
||||
GUI.Label(rect, LABEL, styles.labelCenter);
|
||||
|
||||
if (temp == -1)
|
||||
return;
|
||||
|
||||
if (temp == 0)
|
||||
SettingsService.OpenUserPreferences("Module/Toolbar");
|
||||
else
|
||||
SettingsService.OpenProjectSettings("Module/Toolbar");
|
||||
}
|
||||
|
||||
public override float CalculateWidth()
|
||||
{
|
||||
return 24.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8a8e120b2d684dc2bf1c158296f6e97c
|
||||
timeCreated: 1693489784
|
||||
|
|
@ -6,14 +6,14 @@ using UTools = UnityEditor.Tools;
|
|||
namespace Module.NavigationTool.Editor.Toolbar
|
||||
{
|
||||
[UsedImplicitly]
|
||||
internal sealed class ToolProjectSave : AbstractToolbarDrawer
|
||||
internal sealed class ToolUnityProjectSave : AbstractToolbarDrawer
|
||||
{
|
||||
public override bool Visible => ToolbarProjectSettings.IsProjectSaveEnabled;
|
||||
public override bool Visible => ToolbarUnitySettings.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");
|
||||
private static readonly GUIContent LABEL = new GUIContent(string.Empty, "Saves all changed assets");
|
||||
|
||||
protected override void Draw(Rect rect)
|
||||
{
|
||||
|
|
@ -19,6 +19,7 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
public GUIContent iconSceneSingle;
|
||||
public GUIContent iconDisconnect;
|
||||
public GUIContent iconProject;
|
||||
public GUIContent iconSettings;
|
||||
|
||||
private GUISkin skin;
|
||||
|
||||
|
|
@ -63,6 +64,7 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
iconSceneSingle = EditorGUIUtility.IconContent("d_winbtn_win_max_h");
|
||||
iconDisconnect = EditorGUIUtility.IconContent("d_CacheServerDisconnected");
|
||||
iconProject = EditorGUIUtility.IconContent("Project");
|
||||
iconSettings = new GUIContent(EditorGUIUtility.IconContent("Settings"));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue