Time scale: Added context menu to time scale, so it is possible to reset slider to 1.0

This commit is contained in:
Anders Ejlersen 2025-03-29 17:19:16 +01:00
parent dd80d46ebb
commit 29ab1a90a0
4 changed files with 18 additions and 1 deletions

View file

@ -1,6 +1,7 @@
using JetBrains.Annotations;
using UnityEditor;
using UnityEngine;
using UTools = UnityEditor.Tools;
namespace Module.NavigationTool.Editor.Toolbar
{

View file

@ -28,6 +28,16 @@ namespace Module.NavigationTool.Editor.Toolbar
EditorGUI.LabelField(r0, LABEL_TIME_SCALE, styles.centeredMiniLabel);
EditorGUI.LabelField(r2, LABEL_TIME_VALUE, styles.centeredMiniLabel);
if (Event.current.keyCode == KeyCode.Mouse1 && rect.Contains(Event.current.mousePosition))
{
GenericMenu menu = new GenericMenu();
menu.AddItem(new GUIContent("Reset"), false, () => Time.timeScale = 1f);
menu.ShowAsContext();
Event.current.Use();
}
float temp = GUI.HorizontalSlider(r1, value, ToolbarTimeSettings.TimeScaleMinValue, ToolbarTimeSettings.TimeScaleMaxValue);
temp = Mathf.Clamp(temp, ToolbarTimeSettings.TimeScaleMinValue, ToolbarTimeSettings.TimeScaleMaxValue);