Strip debug logging from the game, fix screen weirdness

This commit is contained in:
Michal Pikulski
2025-10-14 15:53:58 +02:00
parent 18be597424
commit e8180b21bf
65 changed files with 768 additions and 411 deletions

View File

@@ -3,6 +3,7 @@ using AppleHills.Core.Settings;
using System;
using System.Collections.Generic;
using AppleHills.Core.Interfaces;
using Core;
using UI;
/// <summary>
@@ -81,11 +82,11 @@ public class GameManager : MonoBehaviour
pauseMenu.OnGamePaused += OnPauseMenuPaused;
pauseMenu.OnGameResumed += OnPauseMenuResumed;
Debug.Log("[GameManager] Subscribed to PauseMenu events");
Logging.Debug("[GameManager] Subscribed to PauseMenu events");
}
else
{
Debug.LogWarning("[GameManager] PauseMenu not found. Pause functionality won't work properly.");
Logging.Warning("[GameManager] PauseMenu not found. Pause functionality won't work properly.");
}
}
@@ -116,7 +117,7 @@ public class GameManager : MonoBehaviour
component.Pause();
}
Debug.Log($"[GameManager] Registered pausable component: {(component as MonoBehaviour)?.name ?? "Unknown"}");
Logging.Debug($"[GameManager] Registered pausable component: {(component as MonoBehaviour)?.name ?? "Unknown"}");
}
}
@@ -129,7 +130,7 @@ public class GameManager : MonoBehaviour
if (component != null && _pausableComponents.Contains(component))
{
_pausableComponents.Remove(component);
Debug.Log($"[GameManager] Unregistered pausable component: {(component as MonoBehaviour)?.name ?? "Unknown"}");
Logging.Debug($"[GameManager] Unregistered pausable component: {(component as MonoBehaviour)?.name ?? "Unknown"}");
}
}
@@ -167,7 +168,7 @@ public class GameManager : MonoBehaviour
// Broadcast pause event
OnGamePaused?.Invoke();
Debug.Log($"[GameManager] Game paused. Paused {_pausableComponents.Count} components.");
Logging.Debug($"[GameManager] Game paused. Paused {_pausableComponents.Count} components.");
}
/// <summary>
@@ -188,7 +189,7 @@ public class GameManager : MonoBehaviour
// Broadcast resume event
OnGameResumed?.Invoke();
Debug.Log($"[GameManager] Game resumed. Resumed {_pausableComponents.Count} components.");
Logging.Debug($"[GameManager] Game resumed. Resumed {_pausableComponents.Count} components.");
}
/// <summary>
@@ -204,7 +205,7 @@ public class GameManager : MonoBehaviour
private void InitializeSettings()
{
Debug.Log("Starting settings initialization...");
Logging.Debug("Starting settings initialization...");
// Load settings synchronously
var playerSettings = SettingsProvider.Instance.LoadSettingsSynchronous<PlayerFollowerSettings>();
@@ -215,7 +216,7 @@ public class GameManager : MonoBehaviour
if (playerSettings != null)
{
ServiceLocator.Register<IPlayerFollowerSettings>(playerSettings);
Debug.Log("PlayerFollowerSettings registered successfully");
Logging.Debug("PlayerFollowerSettings registered successfully");
}
else
{
@@ -225,7 +226,7 @@ public class GameManager : MonoBehaviour
if (interactionSettings != null)
{
ServiceLocator.Register<IInteractionSettings>(interactionSettings);
Debug.Log("InteractionSettings registered successfully");
Logging.Debug("InteractionSettings registered successfully");
}
else
{
@@ -235,7 +236,7 @@ public class GameManager : MonoBehaviour
if (minigameSettings != null)
{
ServiceLocator.Register<IDivingMinigameSettings>(minigameSettings);
Debug.Log("MinigameSettings registered successfully");
Logging.Debug("MinigameSettings registered successfully");
}
else
{
@@ -246,11 +247,11 @@ public class GameManager : MonoBehaviour
_settingsLoaded = playerSettings != null && interactionSettings != null && minigameSettings != null;
if (_settingsLoaded)
{
Debug.Log("All settings loaded and registered with ServiceLocator");
Logging.Debug("All settings loaded and registered with ServiceLocator");
}
else
{
Debug.LogWarning("Some settings failed to load - check that all settings assets exist and are marked as Addressables");
Logging.Warning("Some settings failed to load - check that all settings assets exist and are marked as Addressables");
}
}
@@ -259,7 +260,7 @@ public class GameManager : MonoBehaviour
/// </summary>
private void InitializeDeveloperSettings()
{
Debug.Log("Starting developer settings initialization...");
Logging.Debug("Starting developer settings initialization...");
// Load developer settings
var divingDevSettings = DeveloperSettingsProvider.Instance.GetSettings<DivingDeveloperSettings>();
@@ -268,11 +269,11 @@ public class GameManager : MonoBehaviour
if (_developerSettingsLoaded)
{
Debug.Log("All developer settings loaded successfully");
Logging.Debug("All developer settings loaded successfully");
}
else
{
Debug.LogWarning("Some developer settings failed to load");
Logging.Warning("Some developer settings failed to load");
}
}

View File

@@ -13,11 +13,5 @@
{
UnityEngine.Debug.LogWarning(message);
}
[System.Diagnostics.Conditional("ENABLE_LOG")]
public static void Error(object message)
{
UnityEngine.Debug.LogError(message);
}
}
}

View File

@@ -123,7 +123,7 @@ namespace Core
var scene = SceneManager.GetSceneByName(sceneName);
if (!scene.isLoaded)
{
Debug.LogWarning($"SceneManagerService: Attempted to unload scene '{sceneName}', but it is not loaded.");
Logging.Warning($"SceneManagerService: Attempted to unload scene '{sceneName}', but it is not loaded.");
return;
}
SceneUnloadStarted?.Invoke(sceneName);
@@ -264,6 +264,11 @@ namespace Core
// Tracks the currently loaded gameplay scene (not persistent/bootstrapper)
public string CurrentGameplayScene { get; private set; } = "MainMenu";
public async Task ReloadCurrentScene(IProgress<float> progress = null)
{
await SwitchSceneAsync(CurrentGameplayScene, progress);
}
// Switches from current gameplay scene to a new one
public async Task SwitchSceneAsync(string newSceneName, IProgress<float> progress = null)
{
@@ -277,7 +282,7 @@ namespace Core
DestroyImmediate(astar.gameObject);
}
// Unload previous gameplay scene (if not BootstrapScene and not same as new)
if (!string.IsNullOrEmpty(CurrentGameplayScene) && CurrentGameplayScene != newSceneName && CurrentGameplayScene != BootstrapSceneName)
if (!string.IsNullOrEmpty(CurrentGameplayScene)&& CurrentGameplayScene != BootstrapSceneName)
{
var prevScene = SceneManager.GetSceneByName(CurrentGameplayScene);
if (prevScene.isLoaded)
@@ -286,7 +291,7 @@ namespace Core
}
else
{
Debug.LogWarning($"SceneManagerService: Previous scene '{CurrentGameplayScene}' is not loaded, skipping unload.");
Logging.Warning($"SceneManagerService: Previous scene '{CurrentGameplayScene}' is not loaded, skipping unload.");
}
}
// Ensure BootstrapScene is loaded before loading new scene

View File

@@ -35,6 +35,7 @@ namespace Utility
public GameObject orientationPromptPrefab;
public event Action OnOrientationCorrect;
public event Action OnOrientationIncorrect;
private GameObject _promptInstance;
private ScreenOrientationRequirement _requiredOrientation;
@@ -139,6 +140,13 @@ namespace Utility
private System.Collections.IEnumerator ContinuousOrientationCheckRoutine()
{
while (!IsOrientationCorrect())
{
yield return new WaitForSeconds(0.5f);
}
_orientationCorrect = true;
OnOrientationCorrect?.Invoke();
while (true)
{
// Wait for a short interval before checking again
@@ -147,33 +155,11 @@ namespace Utility
// Check if orientation is now incorrect
if (!IsOrientationCorrect())
{
// Pause the game using DivingGameManager
if (DivingGameManager.Instance != null)
{
DivingGameManager.Instance.Pause();
}
// Show the orientation prompt
OnOrientationIncorrect?.Invoke();;
InputManager.Instance.SetInputMode(InputMode.UI);
ShowPrompt();
// Wait until orientation is correct again
while (!IsOrientationCorrect())
{
yield return new WaitForSeconds(0.2f);
}
// Hide the prompt when orientation is correct again
if (_promptInstance != null)
{
Destroy(_promptInstance);
_promptInstance = null;
}
// Resume the game using DivingGameManager
if (DivingGameManager.Instance != null)
{
DivingGameManager.Instance.DoResume();
}
_continuousOrientationCheckCoroutine = StartCoroutine(ContinuousOrientationCheckRoutine());
yield break; // Exit this coroutine
}
}
}

View File

@@ -2,6 +2,7 @@
using UnityEngine;
using UnityEngine.AddressableAssets;
using System;
using Core;
namespace AppleHills.Core.Settings
{
@@ -91,13 +92,13 @@ namespace AppleHills.Core.Settings
Debug.LogError($"Failed to load developer settings at '{key}': {e.Message}");
}
Debug.LogWarning($"Developer settings of type {type.Name} not found at addressable path '{key}'");
Logging.Warning($"Developer settings of type {type.Name} not found at addressable path '{key}'");
// Fallback to Resources for backward compatibility
T resourcesSettings = Resources.Load<T>($"{_addressablePath}/{type.Name}");
if (resourcesSettings != null)
{
Debug.Log($"Found developer settings in Resources instead of Addressables at '{_addressablePath}/{type.Name}'");
Logging.Debug($"Found developer settings in Resources instead of Addressables at '{_addressablePath}/{type.Name}'");
_settingsCache[type] = resourcesSettings;
return resourcesSettings;
}

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using Core;
using UnityEngine;
namespace AppleHills.Core.Settings
@@ -20,7 +21,7 @@ namespace AppleHills.Core.Settings
public static void Register<T>(T service) where T : class
{
_services[typeof(T)] = service;
Debug.Log($"Service registered: {typeof(T).Name}");
Logging.Debug($"Service registered: {typeof(T).Name}");
}
/// <summary>
@@ -35,7 +36,7 @@ namespace AppleHills.Core.Settings
return service as T;
}
Debug.LogWarning($"Service of type {typeof(T).Name} not found!");
Logging.Warning($"Service of type {typeof(T).Name} not found!");
return null;
}
@@ -45,7 +46,7 @@ namespace AppleHills.Core.Settings
public static void Clear()
{
_services.Clear();
Debug.Log("All services cleared");
Logging.Debug("All services cleared");
}
}
}