mirror of
https://github.com/originalnicodr/CinematicUnityExplorer.git
synced 2026-10-11 01:48:07 +08:00
Modified the TimeScaleController to work in tandem with UnityExplorer's native time scale control.
This commit is contained in:
1 parent
f0b594fd30
commit
ef4401fac0
3 files changed
+17
-12
No files matched your search
@@ -78,7 +78,7 @@ namespace UnityExplorer
|
||||
public TimeScaleController(System.IntPtr ptr) : base(ptr) { }
|
||||
#endif
|
||||
|
||||
bool pause;
|
||||
public bool pause;
|
||||
bool settingTimeScale;
|
||||
|
||||
internal static void Setup()
|
||||
@@ -96,12 +96,13 @@ namespace UnityExplorer
|
||||
public void Update()
|
||||
{
|
||||
if (InputManager.GetKeyDown(KeyCode.Pause))
|
||||
{
|
||||
pause = !pause;
|
||||
|
||||
if (pause)
|
||||
SetTimeScale(0f);
|
||||
else
|
||||
SetTimeScale(1f);
|
||||
if (pause)
|
||||
SetTimeScale(0f);
|
||||
else
|
||||
SetTimeScale(1f);
|
||||
}
|
||||
}
|
||||
|
||||
void SetTimeScale(float time)
|
||||
|
||||
@@ -28,15 +28,19 @@ namespace UnityExplorer.UI.Widgets
|
||||
InputFieldRef timeInput;
|
||||
float desiredTime;
|
||||
bool settingTimeScale;
|
||||
TimeScaleController timeScaleController = GameObject.Find("TimeScaleController").GetComponent<TimeScaleController>();
|
||||
|
||||
public void Update()
|
||||
{
|
||||
// Fallback in case Time.timeScale patch failed for whatever reason
|
||||
if (locked)
|
||||
SetTimeScale(desiredTime);
|
||||
//We don't want Unity Explorer's native time scale control to interfere with ours.
|
||||
if (!timeScaleController.pause){
|
||||
// Fallback in case Time.timeScale patch failed for whatever reason
|
||||
if (locked)
|
||||
SetTimeScale(desiredTime);
|
||||
|
||||
if (!timeInput.Component.isFocused)
|
||||
timeInput.Text = Time.timeScale.ToString("F2");
|
||||
if (!timeInput.Component.isFocused)
|
||||
timeInput.Text = Time.timeScale.ToString("F2");
|
||||
}
|
||||
}
|
||||
|
||||
void SetTimeScale(float time)
|
||||
@@ -107,7 +111,7 @@ namespace UnityExplorer.UI.Widgets
|
||||
|
||||
static bool Prefix_Time_set_timeScale()
|
||||
{
|
||||
return !Instance.locked || Instance.settingTimeScale;
|
||||
return Instance.timeScaleController.pause || !Instance.locked || Instance.settingTimeScale;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user