1.3.2: Added min & max values for time slider and modifiable in settings

This commit is contained in:
Anders Ejlersen 2022-01-28 21:48:29 +01:00
parent 21cd509506
commit 40fa4d7151
4 changed files with 50 additions and 7 deletions

View file

@ -15,14 +15,18 @@ namespace Module.NavigationTool.Editor.Toolbar
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);
var r0 = new Rect(rect.x, rect.y - 2.0f, rect.width, rect.height * 0.5f);
var r1 = new Rect(rect.x + 4.0f, rect.y + 2.0f, rect.width - 8.0f, rect.height * 0.5f);
var r2 = new Rect(rect.x, r1.yMax, rect.width, rect.height * 0.5f);
if (!Mathf.Approximately(value, temp) && value > -0.001f && value < 1.001f)
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);
if (!Mathf.Approximately(value, temp))
Time.timeScale = temp;
}