mirror of
https://github.com/originalnicodr/CinematicUnityExplorer.git
synced 2026-10-11 09:58:02 +08:00
Added a pause hotkey.
This commit is contained in:
1 parent
c2ee4979bb
commit
f0b594fd30
3 files changed
+46
No files matched your search
@@ -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<TimeScaleController>();
|
||||
#endif
|
||||
|
||||
GameObject obj = new("TimeScaleController");
|
||||
DontDestroyOnLoad(obj);
|
||||
obj.hideFlags = HideFlags.HideAndDontSave;
|
||||
Instance = obj.AddComponent<TimeScaleController>();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user