Pause timescale when game is paused

This commit is contained in:
Michal Pikulski
2025-10-27 15:21:23 +01:00
parent 7005b70a0d
commit dad1f6498d
10 changed files with 57 additions and 1100 deletions

View File

@@ -123,8 +123,12 @@ namespace Core
/// <param name="shouldPause">True to pause; false to resume</param>
private void ApplyPause(bool shouldPause)
{
// TODO: Do we want to stop time?
// Time.timeScale = shouldPause ? 0f : 1f;
// Only affect timescale if debug setting allows it
var debugSettings = GetDeveloperSettings<DebugSettings>();
if (debugSettings != null && debugSettings.PauseTimeOnPauseGame)
{
Time.timeScale = shouldPause ? 0f : 1f;
}
// Notify registered components
foreach (var component in _pausableComponents)
@@ -213,8 +217,9 @@ namespace Core
// Load developer settings
var divingDevSettings = DeveloperSettingsProvider.Instance.GetSettings<DivingDeveloperSettings>();
var debugSettings = DeveloperSettingsProvider.Instance.GetSettings<DebugSettings>();
_developerSettingsLoaded = divingDevSettings != null;
_developerSettingsLoaded = divingDevSettings != null && debugSettings != null;
if (_developerSettingsLoaded)
{

View File

@@ -25,8 +25,13 @@ namespace AppleHills.Core.Settings
[Tooltip("Should debug messages be show on screen in Editor")]
[SerializeField] private bool showDebugUiMessages = false;
[Header("Game Behavior Options")]
[Tooltip("Should Time.timeScale be set to 0 when the game is paused")]
[SerializeField] private bool pauseTimeOnPauseGame = true;
// Property getters
public bool ShowDebugUiMessages => showDebugUiMessages;
public bool PauseTimeOnPauseGame => pauseTimeOnPauseGame;
public override void OnValidate()
{