1.5.0: Added interface and utility class for adding settings to toolbar settings provider

This commit is contained in:
Anders Ejlersen 2022-02-14 20:57:58 +01:00
parent 12de62dabb
commit 91c9504910
25 changed files with 272 additions and 133 deletions

View 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);
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 05811b28871541ec868123c6176c987f
timeCreated: 1644864282

View 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);
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 40d094d8314a485988bb647a72b78fb4
timeCreated: 1644864987

View 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;
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4ff04b8c4eb645eba58747d2399f8825
timeCreated: 1644865203

View 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);
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ce06d92a6c084745bb04f8468a3b2802
timeCreated: 1644865309