Files
AppleHillsProduction/Assets/Scripts/Core/SettingsAccess.cs
tschesky 63cb3f1a8c Revamp the settings system (#7)
- A Settings Provider system to utilize addressables for loading settings at runtime
- An editor UI for easy modifications of the settings objects
- A split out developer settings functionality to keep gameplay and nitty-gritty details separately
- Most settings migrated out of game objects and into the new system
- An additional Editor utility for fetching the settings at editor runtime, for gizmos, visualization etc

Co-authored-by: Michal Pikulski <michal.a.pikulski@gmail.com>
Co-authored-by: AlexanderT <alexander@foolhardyhorizons.com>
Reviewed-on: #7
2025-09-24 13:33:43 +00:00

58 lines
2.0 KiB
C#

using UnityEngine;
namespace AppleHills
{
/// <summary>
/// Unified access to settings in both editor and play mode
/// </summary>
public static class SettingsAccess
{
// Delegate type for editor-only settings providers
public delegate float GetSettingsValueDelegate();
// Static delegates that will be set by editor code
private static GetSettingsValueDelegate getPlayerStopDistanceProvider;
private static GetSettingsValueDelegate getPlayerStopDistanceDirectInteractionProvider;
// Editor-only method to set up providers - will be called from editor code
public static void SetupEditorProviders(
GetSettingsValueDelegate playerStopDistanceProvider,
GetSettingsValueDelegate playerStopDistanceDirectInteractionProvider)
{
#if UNITY_EDITOR
if (!Application.isPlaying)
{
getPlayerStopDistanceProvider = playerStopDistanceProvider;
getPlayerStopDistanceDirectInteractionProvider = playerStopDistanceDirectInteractionProvider;
}
#endif
}
public static float GetPlayerStopDistance()
{
#if UNITY_EDITOR
if (!Application.isPlaying && getPlayerStopDistanceProvider != null)
{
return getPlayerStopDistanceProvider();
}
#endif
return GameManager.Instance.PlayerStopDistance;
}
public static float GetPlayerStopDistanceDirectInteraction()
{
#if UNITY_EDITOR
if (!Application.isPlaying && getPlayerStopDistanceDirectInteractionProvider != null)
{
return getPlayerStopDistanceDirectInteractionProvider();
}
#endif
return GameManager.Instance.PlayerStopDistanceDirectInteraction;
}
// Add more methods as needed for other settings
}
}