mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-17 22:48:04 +08:00
Maintain last timeScale value
This commit is contained in:
parent
e85ea6ac3a
commit
342fc6bdb8
@ -164,6 +164,22 @@ namespace UnityExplorer.UI
|
|||||||
InputFieldRef.UpdateInstances();
|
InputFieldRef.UpdateInstances();
|
||||||
UIBehaviourModel.UpdateInstances();
|
UIBehaviourModel.UpdateInstances();
|
||||||
|
|
||||||
|
// update the timescale value
|
||||||
|
if (!timeInput.Component.isFocused && lastTimeScale != Time.timeScale)
|
||||||
|
{
|
||||||
|
if (pauseButtonPausing && Time.timeScale != 0.0f)
|
||||||
|
{
|
||||||
|
pauseButtonPausing = false;
|
||||||
|
OnPauseButtonToggled();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pauseButtonPausing)
|
||||||
|
{
|
||||||
|
timeInput.Text = Time.timeScale.ToString("F2");
|
||||||
|
lastTimeScale = Time.timeScale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// check screen dimension change
|
// check screen dimension change
|
||||||
if (Screen.width != lastScreenWidth || Screen.height != lastScreenHeight)
|
if (Screen.width != lastScreenWidth || Screen.height != lastScreenHeight)
|
||||||
OnScreenDimensionsChanged();
|
OnScreenDimensionsChanged();
|
||||||
@ -274,13 +290,14 @@ namespace UnityExplorer.UI
|
|||||||
{
|
{
|
||||||
pauseButtonPausing = !pauseButtonPausing;
|
pauseButtonPausing = !pauseButtonPausing;
|
||||||
|
|
||||||
if (pauseButtonPausing)
|
Time.timeScale = pauseButtonPausing ? 0f : lastTimeScale;
|
||||||
lastTimeScale = Time.timeScale;
|
|
||||||
|
|
||||||
float scale = pauseButtonPausing ? 0f : lastTimeScale;
|
OnPauseButtonToggled();
|
||||||
Time.timeScale = scale;
|
}
|
||||||
|
|
||||||
timeInput.Component.text = scale.ToString("F2");
|
private static void OnPauseButtonToggled()
|
||||||
|
{
|
||||||
|
timeInput.Component.text = Time.timeScale.ToString("F2");
|
||||||
timeInput.Component.readOnly = pauseButtonPausing;
|
timeInput.Component.readOnly = pauseButtonPausing;
|
||||||
timeInput.Component.textComponent.color = pauseButtonPausing ? Color.grey : Color.white;
|
timeInput.Component.textComponent.color = pauseButtonPausing ? Color.grey : Color.white;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user