1.2.0: added TimeScale to toolbar
This commit is contained in:
parent
9802f8aaa3
commit
65ca5dd355
|
|
@ -7,16 +7,17 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
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_TIME_SCALE_ENABLED = "ToolbarSettings.IsTimeScaleEnabled";
|
||||
|
||||
public static bool IsUiEnabled
|
||||
{
|
||||
get => EditorPrefs.GetBool(PREF_IS_UI_ENABLED, true);
|
||||
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, true);
|
||||
get => EditorPrefs.GetBool(PREF_IS_UI_LAYER_ENABLED, false);
|
||||
set => EditorPrefs.SetBool(PREF_IS_UI_LAYER_ENABLED, value);
|
||||
}
|
||||
|
||||
|
|
@ -25,5 +26,11 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
get => EditorPrefs.GetBool(PREF_IS_SCENE_ENABLED, true);
|
||||
set => EditorPrefs.SetBool(PREF_IS_SCENE_ENABLED, value);
|
||||
}
|
||||
|
||||
public static bool IsTimeScaleEnabled
|
||||
{
|
||||
get => EditorPrefs.GetBool(PREF_IS_TIME_SCALE_ENABLED, false);
|
||||
set => EditorPrefs.SetBool(PREF_IS_TIME_SCALE_ENABLED, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -34,6 +34,10 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Scene", EditorStyles.boldLabel);
|
||||
ToolbarSettings.IsSceneEnabled = EditorGUILayout.Toggle("Enable Scene picker", ToolbarSettings.IsSceneEnabled);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Time", EditorStyles.boldLabel);
|
||||
ToolbarSettings.IsTimeScaleEnabled = EditorGUILayout.Toggle("Enable Time Scale slider", ToolbarSettings.IsTimeScaleEnabled);
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
|
|
|||
34
Editor/Toolbar/Tools/ToolTimeScale.cs
Normal file
34
Editor/Toolbar/Tools/ToolTimeScale.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
using JetBrains.Annotations;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UTools = UnityEditor.Tools;
|
||||
|
||||
namespace Module.NavigationTool.Editor.Toolbar
|
||||
{
|
||||
[UsedImplicitly]
|
||||
internal sealed class ToolTimeScale : AbstractToolbarDrawer
|
||||
{
|
||||
public override bool Visible => ToolbarSettings.IsTimeScaleEnabled;
|
||||
public override bool Enabled => true;
|
||||
public override EToolbarPlacement Placement => EToolbarPlacement.Left;
|
||||
public override int Priority => (int)EToolbarPriority.Low;
|
||||
|
||||
protected override void Draw(Rect rect)
|
||||
{
|
||||
var r0 = new Rect(rect.x, rect.y, rect.width, rect.height * 0.5f);
|
||||
EditorGUI.LabelField(r0, "Time scale", EditorStyles.centeredGreyMiniLabel);
|
||||
|
||||
var r1 = new Rect(rect.x + 4.0f, rect.y + rect.height * 0.25f, rect.width - 8.0f, rect.height * 0.5f);
|
||||
float value = Time.timeScale;
|
||||
float temp = GUI.HorizontalSlider(r1, value, 0.0f, 1.0f);
|
||||
|
||||
if (!Mathf.Approximately(value, temp) && value > -0.001f && value < 1.001f)
|
||||
Time.timeScale = temp;
|
||||
}
|
||||
|
||||
public override float CalculateWidth()
|
||||
{
|
||||
return 100.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Editor/Toolbar/Tools/ToolTimeScale.cs.meta
Normal file
3
Editor/Toolbar/Tools/ToolTimeScale.cs.meta
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 757111b1895840149b30b5945b0c8ad1
|
||||
timeCreated: 1641415892
|
||||
|
|
@ -25,6 +25,7 @@ Three tools are available from start:
|
|||
* UI Layer: Toggle the UI layer on/off
|
||||
* UI Canvas: Select and center the camera on any Canvases in the scene
|
||||
* Scene: Load any scene in the project easily by using the dropdown
|
||||
* Time Scale: Adjust the time scale from [0;1] from a slider
|
||||
|
||||
|
||||
### Customization
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "com.module.navigationtool",
|
||||
"version": "1.1.0",
|
||||
"version": "1.2.0",
|
||||
"displayName": "Module.NavigationTool",
|
||||
"description": "Support for navigation tools, like favorites, history and toolbars",
|
||||
"unity": "2019.2",
|
||||
|
|
|
|||
Loading…
Reference in a new issue