1.2.0: added TimeScale to toolbar
This commit is contained in:
parent
9802f8aaa3
commit
65ca5dd355
6 changed files with 52 additions and 3 deletions
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue