diff --git a/UnityEditorPackage/Runtime/UnityExplorer.STANDALONE.Mono.dll b/UnityEditorPackage/Runtime/UnityExplorer.STANDALONE.Mono.dll index 90d0e81..243ac28 100644 Binary files a/UnityEditorPackage/Runtime/UnityExplorer.STANDALONE.Mono.dll and b/UnityEditorPackage/Runtime/UnityExplorer.STANDALONE.Mono.dll differ diff --git a/src/ExplorerBehaviour.cs b/src/ExplorerBehaviour.cs index 50fd53a..b42c086 100644 --- a/src/ExplorerBehaviour.cs +++ b/src/ExplorerBehaviour.cs @@ -1,4 +1,5 @@ using UnityExplorer.UI; +using UniverseLib.Input; #if CPP #if UNHOLLOWER using UnhollowerRuntimeLib; @@ -68,4 +69,46 @@ namespace UnityExplorer catch { } } } + + public class TimeScaleController : MonoBehaviour + { + internal static TimeScaleController Instance { get; private set; } + +#if CPP + public TimeScaleController(System.IntPtr ptr) : base(ptr) { } +#endif + + bool pause; + bool settingTimeScale; + + internal static void Setup() + { +#if CPP + ClassInjector.RegisterTypeInIl2Cpp(); +#endif + + GameObject obj = new("TimeScaleController"); + DontDestroyOnLoad(obj); + obj.hideFlags = HideFlags.HideAndDontSave; + Instance = obj.AddComponent(); + } + + public void Update() + { + if (InputManager.GetKeyDown(KeyCode.Pause)) + pause = !pause; + + if (pause) + SetTimeScale(0f); + else + SetTimeScale(1f); + } + + void SetTimeScale(float time) + { + settingTimeScale = true; + Time.timeScale = time; + settingTimeScale = false; + } + } } diff --git a/src/ExplorerCore.cs b/src/ExplorerCore.cs index 05195af..c46e060 100644 --- a/src/ExplorerCore.cs +++ b/src/ExplorerCore.cs @@ -55,6 +55,9 @@ namespace UnityExplorer UERuntimeHelper.Init(); ExplorerBehaviour.Setup(); UnityCrashPrevention.Init(); + + //Extra inits + TimeScaleController.Setup(); } // Do a delayed setup so that objects aren't destroyed instantly.