1.5.0: Added interface and utility class for adding settings to toolbar settings provider
This commit is contained in:
parent
12de62dabb
commit
91c9504910
9
Editor/Toolbar/Settings/IToolbarSettings.cs
Normal file
9
Editor/Toolbar/Settings/IToolbarSettings.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
namespace Module.NavigationTool.Editor.Toolbar
|
||||
{
|
||||
public interface IToolbarSettings
|
||||
{
|
||||
string Title { get; }
|
||||
|
||||
void Draw();
|
||||
}
|
||||
}
|
||||
3
Editor/Toolbar/Settings/IToolbarSettings.cs.meta
Normal file
3
Editor/Toolbar/Settings/IToolbarSettings.cs.meta
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 66bccfd6abba42ba9d07f0d746d6179d
|
||||
timeCreated: 1644864241
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
using UnityEditor;
|
||||
|
||||
namespace Module.NavigationTool.Editor.Toolbar
|
||||
{
|
||||
internal static class ToolbarSettings
|
||||
{
|
||||
private const string PREF_IS_UI_ENABLED = "ToolbarSettings_IsUiEnabled";
|
||||
private const string PREF_IS_UI_LAYER_ENABLED = "ToolbarSettings_IsUiLayerEnabled";
|
||||
private const string PREF_IS_SCENE_ENABLED = "ToolbarSettings_IsSceneEnabled";
|
||||
private const string PREF_IS_BUILD_ENABLED = "ToolbarSettings.IsBuildEnabled";
|
||||
private const string PREF_IS_BUILD_AND_RUN_ENABLED = "ToolbarSettings.IsBuildAndRunEnabled";
|
||||
private const string PREF_IS_TIME_SCALE_ENABLED = "ToolbarSettings.IsTimeScaleEnabled";
|
||||
private const string PREF_TIME_SCALE_MIN = "ToolbarSettings.TimeScaleMin";
|
||||
private const string PREF_TIME_SCALE_MAX = "ToolbarSettings.TimeScaleMax";
|
||||
|
||||
public static bool IsUiEnabled
|
||||
{
|
||||
get => EditorPrefs.GetBool(PREF_IS_UI_ENABLED, false);
|
||||
set => EditorPrefs.SetBool(PREF_IS_UI_ENABLED, value);
|
||||
}
|
||||
|
||||
public static bool IsUiLayerEnabled
|
||||
{
|
||||
get => EditorPrefs.GetBool(PREF_IS_UI_LAYER_ENABLED, false);
|
||||
set => EditorPrefs.SetBool(PREF_IS_UI_LAYER_ENABLED, value);
|
||||
}
|
||||
|
||||
public static bool IsSceneEnabled
|
||||
{
|
||||
get => EditorPrefs.GetBool(PREF_IS_SCENE_ENABLED, true);
|
||||
set => EditorPrefs.SetBool(PREF_IS_SCENE_ENABLED, value);
|
||||
}
|
||||
|
||||
public static bool IsBuildEnabled
|
||||
{
|
||||
get => EditorPrefs.GetBool(PREF_IS_BUILD_ENABLED, false);
|
||||
set => EditorPrefs.SetBool(PREF_IS_BUILD_ENABLED, value);
|
||||
}
|
||||
|
||||
public static bool IsBuildAndRunEnabled
|
||||
{
|
||||
get => EditorPrefs.GetBool(PREF_IS_BUILD_AND_RUN_ENABLED, true);
|
||||
set => EditorPrefs.SetBool(PREF_IS_BUILD_AND_RUN_ENABLED, value);
|
||||
}
|
||||
|
||||
public static bool IsTimeScaleEnabled
|
||||
{
|
||||
get => EditorPrefs.GetBool(PREF_IS_TIME_SCALE_ENABLED, false);
|
||||
set => EditorPrefs.SetBool(PREF_IS_TIME_SCALE_ENABLED, value);
|
||||
}
|
||||
|
||||
public static float TimeScaleMinValue
|
||||
{
|
||||
get => EditorPrefs.GetFloat(PREF_TIME_SCALE_MIN, 0.0f);
|
||||
set => EditorPrefs.SetFloat(PREF_TIME_SCALE_MIN, value);
|
||||
}
|
||||
|
||||
public static float TimeScaleMaxValue
|
||||
{
|
||||
get => EditorPrefs.GetFloat(PREF_TIME_SCALE_MAX, 1.0f);
|
||||
set => EditorPrefs.SetFloat(PREF_TIME_SCALE_MAX, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ee57c1a04c9448e585e7e524886bdeda
|
||||
timeCreated: 1639924440
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
|
|
@ -6,67 +7,50 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
internal static class ToolbarSettingsProvider
|
||||
{
|
||||
private static Styles STYLES;
|
||||
private static IToolbarSettings[] SETTINGS;
|
||||
|
||||
[SettingsProvider]
|
||||
public static SettingsProvider GetProvider()
|
||||
{
|
||||
Initialize();
|
||||
var keywords = new List<string> { "Toolbar" };
|
||||
|
||||
for (var i = 0; i < SETTINGS.Length; i++)
|
||||
{
|
||||
keywords.Add(SETTINGS[i].Title);
|
||||
}
|
||||
|
||||
return new SettingsProvider("Module/Toolbar", SettingsScope.User)
|
||||
{
|
||||
label = "Toolbar",
|
||||
keywords = new[] { "Scene", "UI", "Toolbar" },
|
||||
keywords = keywords.ToArray(),
|
||||
guiHandler = OnGui
|
||||
};
|
||||
}
|
||||
|
||||
private static void OnGui(string searchContext)
|
||||
private static void Initialize()
|
||||
{
|
||||
if (STYLES == null)
|
||||
STYLES = new Styles();
|
||||
if (SETTINGS == null)
|
||||
SETTINGS = ToolbarSettingsUtility.GetAllSettings();
|
||||
}
|
||||
|
||||
STYLES.Initialize((GUI.skin));
|
||||
private static void OnGui(string searchContext)
|
||||
{
|
||||
Initialize();
|
||||
STYLES.Initialize(GUI.skin);
|
||||
|
||||
EditorGUILayout.BeginVertical(STYLES.settingsGroup);
|
||||
{
|
||||
EditorGUILayout.LabelField("UI", EditorStyles.boldLabel);
|
||||
ToolbarSettings.IsUiEnabled = EditorGUILayout.Toggle("Enable Canvas picker", ToolbarSettings.IsUiEnabled);
|
||||
ToolbarSettings.IsUiLayerEnabled = EditorGUILayout.Toggle("Enable Layer toggle", ToolbarSettings.IsUiLayerEnabled);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Scene", EditorStyles.boldLabel);
|
||||
ToolbarSettings.IsSceneEnabled = EditorGUILayout.Toggle("Enable Scene picker", ToolbarSettings.IsSceneEnabled);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Build Target", EditorStyles.boldLabel);
|
||||
ToolbarSettings.IsBuildEnabled = EditorGUILayout.Toggle("Enable Build Target picker", ToolbarSettings.IsBuildEnabled);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Time", EditorStyles.boldLabel);
|
||||
ToolbarSettings.IsTimeScaleEnabled = EditorGUILayout.Toggle("Enable Time Scale slider", ToolbarSettings.IsTimeScaleEnabled);
|
||||
|
||||
GUI.enabled = ToolbarSettings.IsTimeScaleEnabled;
|
||||
float timeScaleMinValue = EditorGUILayout.FloatField("Min Value", ToolbarSettings.TimeScaleMinValue);
|
||||
float timeScaleMaxValue = EditorGUILayout.FloatField("Max Value", ToolbarSettings.TimeScaleMaxValue);
|
||||
|
||||
if (!Mathf.Approximately(timeScaleMinValue, ToolbarSettings.TimeScaleMinValue))
|
||||
for (var i = 0; i < SETTINGS.Length; i++)
|
||||
{
|
||||
if (timeScaleMinValue < 0.0f)
|
||||
timeScaleMinValue = 0.0f;
|
||||
IToolbarSettings settings = SETTINGS[i];
|
||||
|
||||
if (timeScaleMinValue > timeScaleMaxValue)
|
||||
timeScaleMaxValue = timeScaleMinValue;
|
||||
EditorGUILayout.LabelField(settings.Title, EditorStyles.boldLabel);
|
||||
settings.Draw();
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
else if (!Mathf.Approximately(timeScaleMaxValue, ToolbarSettings.TimeScaleMaxValue))
|
||||
{
|
||||
if (timeScaleMaxValue < 0.0f)
|
||||
timeScaleMaxValue = 0.0f;
|
||||
|
||||
if (timeScaleMaxValue < timeScaleMinValue)
|
||||
timeScaleMinValue = timeScaleMaxValue;
|
||||
}
|
||||
|
||||
ToolbarSettings.TimeScaleMinValue = timeScaleMinValue;
|
||||
ToolbarSettings.TimeScaleMaxValue = timeScaleMaxValue;
|
||||
GUI.enabled = true;
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,8 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
private static void OnUpdateElements(VisualElement leftAlign, VisualElement rightAlign)
|
||||
{
|
||||
const float HEIGHT = 22.0f;
|
||||
const float ADD_CATEGORY = 2.0f;
|
||||
|
||||
var added = false;
|
||||
|
||||
for (int i = DRAWERS.Length - 1; i >= 0; i--)
|
||||
|
|
@ -61,18 +63,22 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
|
||||
if (drawer.Visible && !valid)
|
||||
{
|
||||
var rect = new Rect(2.0f, 0.0f, drawer.CalculateWidth(), HEIGHT);
|
||||
var rect = new Rect(ADD_CATEGORY, 0.0f, drawer.CalculateWidth(), HEIGHT);
|
||||
drawer.Setup(rect);
|
||||
var container = new ToolbarIMGUIContainer(drawer.OnGUI, drawer.Priority);
|
||||
|
||||
var container = new ToolbarIMGUIContainer(drawer.OnGUI, drawer.Priority);
|
||||
container.style.width = rect.width + 4.0f;
|
||||
DICT_MAPPING.Add(drawer, container);
|
||||
added = true;
|
||||
VisualElement parent;
|
||||
|
||||
if (drawer.Placement == EToolbarPlacement.Left)
|
||||
leftAlign.Add(container);
|
||||
parent = leftAlign;
|
||||
else
|
||||
rightAlign.Add(container);
|
||||
parent = rightAlign;
|
||||
|
||||
container.style.width = rect.width + ADD_CATEGORY * 2.0f;
|
||||
DICT_MAPPING.Add(drawer, container);
|
||||
|
||||
added = true;
|
||||
parent.Add(container);
|
||||
}
|
||||
else if (!drawer.Visible && valid)
|
||||
{
|
||||
|
|
|
|||
3
Editor/Toolbar/Tools/Settings.meta
Normal file
3
Editor/Toolbar/Tools/Settings.meta
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a630457a27194c8b8e93a7d8b2a8ae27
|
||||
timeCreated: 1644864264
|
||||
29
Editor/Toolbar/Tools/Settings/ToolbarBuildSettings.cs
Normal file
29
Editor/Toolbar/Tools/Settings/ToolbarBuildSettings.cs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
using UnityEditor;
|
||||
|
||||
namespace Module.NavigationTool.Editor.Toolbar
|
||||
{
|
||||
internal sealed class ToolbarBuildSettings : IToolbarSettings
|
||||
{
|
||||
public string Title => "Build";
|
||||
|
||||
private const string PREF_IS_BUILD_ENABLED = "ToolbarSettings.IsBuildEnabled";
|
||||
private const string PREF_IS_BUILD_AND_RUN_ENABLED = "ToolbarSettings.IsBuildAndRunEnabled";
|
||||
|
||||
public static bool IsBuildEnabled
|
||||
{
|
||||
get => EditorPrefs.GetBool(PREF_IS_BUILD_ENABLED, false);
|
||||
set => EditorPrefs.SetBool(PREF_IS_BUILD_ENABLED, value);
|
||||
}
|
||||
|
||||
public static bool IsBuildAndRunEnabled
|
||||
{
|
||||
get => EditorPrefs.GetBool(PREF_IS_BUILD_AND_RUN_ENABLED, true);
|
||||
set => EditorPrefs.SetBool(PREF_IS_BUILD_AND_RUN_ENABLED, value);
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
IsBuildEnabled = EditorGUILayout.Toggle("Enable Build Target picker", IsBuildEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 05811b28871541ec868123c6176c987f
|
||||
timeCreated: 1644864282
|
||||
22
Editor/Toolbar/Tools/Settings/ToolbarScenePickerSettings.cs
Normal file
22
Editor/Toolbar/Tools/Settings/ToolbarScenePickerSettings.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
using UnityEditor;
|
||||
|
||||
namespace Module.NavigationTool.Editor.Toolbar
|
||||
{
|
||||
internal sealed class ToolbarScenePickerSettings : IToolbarSettings
|
||||
{
|
||||
public string Title => "Scene";
|
||||
|
||||
private const string PREF_IS_SCENE_ENABLED = "ToolbarSettings_IsSceneEnabled";
|
||||
|
||||
public static bool IsSceneEnabled
|
||||
{
|
||||
get => EditorPrefs.GetBool(PREF_IS_SCENE_ENABLED, true);
|
||||
set => EditorPrefs.SetBool(PREF_IS_SCENE_ENABLED, value);
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
IsSceneEnabled = EditorGUILayout.Toggle("Enable Scene picker", IsSceneEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 40d094d8314a485988bb647a72b78fb4
|
||||
timeCreated: 1644864987
|
||||
62
Editor/Toolbar/Tools/Settings/ToolbarTimeSettings.cs
Normal file
62
Editor/Toolbar/Tools/Settings/ToolbarTimeSettings.cs
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Module.NavigationTool.Editor.Toolbar
|
||||
{
|
||||
internal sealed class ToolbarTimeSettings : IToolbarSettings
|
||||
{
|
||||
public string Title => "Time";
|
||||
|
||||
private const string PREF_IS_TIME_SCALE_ENABLED = "ToolbarSettings.IsTimeScaleEnabled";
|
||||
private const string PREF_TIME_SCALE_MIN = "ToolbarSettings.TimeScaleMin";
|
||||
private const string PREF_TIME_SCALE_MAX = "ToolbarSettings.TimeScaleMax";
|
||||
|
||||
public static bool IsTimeScaleEnabled
|
||||
{
|
||||
get => EditorPrefs.GetBool(PREF_IS_TIME_SCALE_ENABLED, false);
|
||||
set => EditorPrefs.SetBool(PREF_IS_TIME_SCALE_ENABLED, value);
|
||||
}
|
||||
|
||||
public static float TimeScaleMinValue
|
||||
{
|
||||
get => EditorPrefs.GetFloat(PREF_TIME_SCALE_MIN, 0.0f);
|
||||
set => EditorPrefs.SetFloat(PREF_TIME_SCALE_MIN, value);
|
||||
}
|
||||
|
||||
public static float TimeScaleMaxValue
|
||||
{
|
||||
get => EditorPrefs.GetFloat(PREF_TIME_SCALE_MAX, 1.0f);
|
||||
set => EditorPrefs.SetFloat(PREF_TIME_SCALE_MAX, value);
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
IsTimeScaleEnabled = EditorGUILayout.Toggle("Enable Time Scale slider", IsTimeScaleEnabled);
|
||||
|
||||
GUI.enabled = IsTimeScaleEnabled;
|
||||
float timeScaleMinValue = EditorGUILayout.FloatField("Min Value", TimeScaleMinValue);
|
||||
float timeScaleMaxValue = EditorGUILayout.FloatField("Max Value", TimeScaleMaxValue);
|
||||
|
||||
if (!Mathf.Approximately(timeScaleMinValue, TimeScaleMinValue))
|
||||
{
|
||||
if (timeScaleMinValue < 0.0f)
|
||||
timeScaleMinValue = 0.0f;
|
||||
|
||||
if (timeScaleMinValue > timeScaleMaxValue)
|
||||
timeScaleMaxValue = timeScaleMinValue;
|
||||
}
|
||||
else if (!Mathf.Approximately(timeScaleMaxValue, TimeScaleMaxValue))
|
||||
{
|
||||
if (timeScaleMaxValue < 0.0f)
|
||||
timeScaleMaxValue = 0.0f;
|
||||
|
||||
if (timeScaleMaxValue < timeScaleMinValue)
|
||||
timeScaleMinValue = timeScaleMaxValue;
|
||||
}
|
||||
|
||||
TimeScaleMinValue = timeScaleMinValue;
|
||||
TimeScaleMaxValue = timeScaleMaxValue;
|
||||
GUI.enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4ff04b8c4eb645eba58747d2399f8825
|
||||
timeCreated: 1644865203
|
||||
30
Editor/Toolbar/Tools/Settings/ToolbarUiSettings.cs
Normal file
30
Editor/Toolbar/Tools/Settings/ToolbarUiSettings.cs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
using UnityEditor;
|
||||
|
||||
namespace Module.NavigationTool.Editor.Toolbar
|
||||
{
|
||||
internal sealed class ToolbarUiSettings : IToolbarSettings
|
||||
{
|
||||
public string Title => "UI";
|
||||
|
||||
private const string PREF_IS_UI_ENABLED = "ToolbarSettings_IsUiEnabled";
|
||||
private const string PREF_IS_UI_LAYER_ENABLED = "ToolbarSettings_IsUiLayerEnabled";
|
||||
|
||||
public static bool IsUiEnabled
|
||||
{
|
||||
get => EditorPrefs.GetBool(PREF_IS_UI_ENABLED, false);
|
||||
set => EditorPrefs.SetBool(PREF_IS_UI_ENABLED, value);
|
||||
}
|
||||
|
||||
public static bool IsUiLayerEnabled
|
||||
{
|
||||
get => EditorPrefs.GetBool(PREF_IS_UI_LAYER_ENABLED, false);
|
||||
set => EditorPrefs.SetBool(PREF_IS_UI_LAYER_ENABLED, value);
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
IsUiEnabled = EditorGUILayout.Toggle("Enable Canvas picker", IsUiEnabled);
|
||||
IsUiLayerEnabled = EditorGUILayout.Toggle("Enable Layer toggle", IsUiLayerEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Editor/Toolbar/Tools/Settings/ToolbarUiSettings.cs.meta
Normal file
3
Editor/Toolbar/Tools/Settings/ToolbarUiSettings.cs.meta
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ce06d92a6c084745bb04f8468a3b2802
|
||||
timeCreated: 1644865309
|
||||
|
|
@ -8,7 +8,7 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
[UsedImplicitly]
|
||||
internal sealed class ToolBuild : AbstractToolbarDrawer
|
||||
{
|
||||
public override bool Visible => ToolbarSettings.IsBuildEnabled;
|
||||
public override bool Visible => ToolbarBuildSettings.IsBuildEnabled;
|
||||
public override bool Enabled => !Application.isPlaying;
|
||||
public override EToolbarPlacement Placement => EToolbarPlacement.Left;
|
||||
public override int Priority => (int)EToolbarPriority.Low;
|
||||
|
|
@ -50,7 +50,7 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
var rect0 = new Rect(rect.x, rect.y, rect.width - 16.0f, rect.height);
|
||||
var rect1 = new Rect(rect0.xMax, rect.y, 16.0f, rect.height);
|
||||
|
||||
int currentSelected = ToolbarSettings.IsBuildAndRunEnabled ? 1 : 0;
|
||||
int currentSelected = ToolbarBuildSettings.IsBuildAndRunEnabled ? 1 : 0;
|
||||
|
||||
if (GUI.Button(rect0, BUTTON_LIST[currentSelected], styles.buttonNoPadding))
|
||||
{
|
||||
|
|
@ -65,7 +65,7 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
EditorUtility.DisplayCustomMenu(rect, CONTENT_LIST, currentSelected, (userData, options, selected) =>
|
||||
{
|
||||
if (selected != -1)
|
||||
ToolbarSettings.IsBuildAndRunEnabled = selected == 1;
|
||||
ToolbarBuildSettings.IsBuildAndRunEnabled = selected == 1;
|
||||
}, null);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
[UsedImplicitly]
|
||||
internal sealed class ToolBuildTargetPicker : AbstractToolbarDrawer
|
||||
{
|
||||
public override bool Visible => ToolbarSettings.IsBuildEnabled;
|
||||
public override bool Visible => ToolbarBuildSettings.IsBuildEnabled;
|
||||
public override bool Enabled => !Application.isPlaying;
|
||||
public override EToolbarPlacement Placement => EToolbarPlacement.Left;
|
||||
public override int Priority => (int)EToolbarPriority.Low;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
[UsedImplicitly]
|
||||
internal sealed class ToolScenePicker : AbstractToolbarDrawer
|
||||
{
|
||||
public override bool Visible => ToolbarSettings.IsSceneEnabled;
|
||||
public override bool Visible => ToolbarScenePickerSettings.IsSceneEnabled;
|
||||
public override bool Enabled => !EditorApplication.isPlaying && !EditorApplication.isPlayingOrWillChangePlaymode;
|
||||
public override EToolbarPlacement Placement => EToolbarPlacement.Right;
|
||||
public override int Priority => (int)EToolbarPriority.Medium;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
[UsedImplicitly]
|
||||
internal sealed class ToolTimeScale : AbstractToolbarDrawer
|
||||
{
|
||||
public override bool Visible => ToolbarSettings.IsTimeScaleEnabled;
|
||||
public override bool Visible => ToolbarTimeSettings.IsTimeScaleEnabled;
|
||||
public override bool Enabled => true;
|
||||
public override EToolbarPlacement Placement => EToolbarPlacement.Left;
|
||||
public override int Priority => (int)EToolbarPriority.Low;
|
||||
|
|
@ -23,8 +23,8 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
|
||||
EditorGUI.LabelField(r0, "Time scale", EditorStyles.centeredGreyMiniLabel);
|
||||
EditorGUI.LabelField(r2, value.ToString("0.00"), EditorStyles.centeredGreyMiniLabel);
|
||||
float temp = GUI.HorizontalSlider(r1, value, ToolbarSettings.TimeScaleMinValue, ToolbarSettings.TimeScaleMaxValue);
|
||||
temp = Mathf.Clamp(temp, ToolbarSettings.TimeScaleMinValue, ToolbarSettings.TimeScaleMaxValue);
|
||||
float temp = GUI.HorizontalSlider(r1, value, ToolbarTimeSettings.TimeScaleMinValue, ToolbarTimeSettings.TimeScaleMaxValue);
|
||||
temp = Mathf.Clamp(temp, ToolbarTimeSettings.TimeScaleMinValue, ToolbarTimeSettings.TimeScaleMaxValue);
|
||||
|
||||
if (Mathf.Abs(temp - 1.0f) < 0.02f)
|
||||
temp = 1.0f;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
[UsedImplicitly]
|
||||
internal sealed class ToolUICanvasPicker : AbstractToolbarDrawer
|
||||
{
|
||||
public override bool Visible => ToolbarSettings.IsUiEnabled;
|
||||
public override bool Visible => ToolbarUiSettings.IsUiEnabled;
|
||||
public override bool Enabled => (UTools.visibleLayers & (1 << LayerMask.NameToLayer("UI"))) != 0;
|
||||
public override EToolbarPlacement Placement => EToolbarPlacement.Left;
|
||||
public override int Priority => (int)EToolbarPriority.Medium;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
[UsedImplicitly]
|
||||
internal sealed class ToolUILayerToggle : AbstractToolbarDrawer
|
||||
{
|
||||
public override bool Visible => ToolbarSettings.IsUiLayerEnabled;
|
||||
public override bool Visible => ToolbarUiSettings.IsUiLayerEnabled;
|
||||
public override bool Enabled => true;
|
||||
public override EToolbarPlacement Placement => EToolbarPlacement.Left;
|
||||
public override int Priority => (int)EToolbarPriority.Medium - 1;
|
||||
|
|
|
|||
43
Editor/Toolbar/Utilities/ToolbarSettingsUtility.cs
Normal file
43
Editor/Toolbar/Utilities/ToolbarSettingsUtility.cs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Module.NavigationTool.Editor.Toolbar
|
||||
{
|
||||
internal static class ToolbarSettingsUtility
|
||||
{
|
||||
public static IToolbarSettings[] GetAllSettings()
|
||||
{
|
||||
var list = new List<IToolbarSettings>(8);
|
||||
|
||||
try
|
||||
{
|
||||
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||
Type iType = typeof(IToolbarSettings);
|
||||
|
||||
for (var i = 0; i < assemblies.Length; i++)
|
||||
{
|
||||
Assembly assembly = assemblies[i];
|
||||
Type[] types = assembly.GetTypes();
|
||||
|
||||
for (var j = 0; j < types.Length; j++)
|
||||
{
|
||||
Type type = types[j];
|
||||
|
||||
if (!type.IsInterface && !type.IsAbstract && iType.IsAssignableFrom(type))
|
||||
list.Add((IToolbarSettings)FormatterServices.GetUninitializedObject(type));
|
||||
}
|
||||
}
|
||||
|
||||
list.Sort((s0, s1) => string.Compare(s0.Title, s1.Title, StringComparison.Ordinal));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Fail silently
|
||||
}
|
||||
|
||||
return list.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Editor/Toolbar/Utilities/ToolbarSettingsUtility.cs.meta
Normal file
3
Editor/Toolbar/Utilities/ToolbarSettingsUtility.cs.meta
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c951cc6b880347bd9e710b8fee3788c5
|
||||
timeCreated: 1644864048
|
||||
|
|
@ -165,8 +165,6 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||
Type iType = typeof(AbstractToolbarDrawer);
|
||||
|
||||
|
||||
|
||||
for (var i = 0; i < assemblies.Length; i++)
|
||||
{
|
||||
Assembly assembly = assemblies[i];
|
||||
|
|
@ -180,6 +178,8 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
list.Add((AbstractToolbarDrawer)FormatterServices.GetUninitializedObject(type));
|
||||
}
|
||||
}
|
||||
|
||||
list.Sort((t0, t1) => t0.Priority.CompareTo(t1.Priority));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "com.module.navigationtool",
|
||||
"version": "1.4.1",
|
||||
"version": "1.5.0",
|
||||
"displayName": "Module.NavigationTool",
|
||||
"description": "Support for navigation tools, like favorites, history and toolbars",
|
||||
"unity": "2019.2",
|
||||
|
|
|
|||
Loading…
Reference in a new issue