Organize custom scripts and Shared under Assets/Scripts, and delete assembly definition files
This commit is contained in:
79
Assets/Scripts/Baba_yaga/GameSetup/SettingsManager.cs
Normal file
79
Assets/Scripts/Baba_yaga/GameSetup/SettingsManager.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Baba_yaga
|
||||
{
|
||||
[UnityEngine.Scripting.APIUpdating.MovedFrom(true, sourceNamespace: "OnlyScove.Scripts", sourceAssembly: "Opsive.UltimateCharacterController")]
|
||||
public class SettingsManager : MonoBehaviour
|
||||
{
|
||||
public static SettingsManager Instance { get; private set; }
|
||||
|
||||
[BoxGroup("Settings")]
|
||||
[Required]
|
||||
[InlineEditor]
|
||||
[SerializeField] private GameSettings settings;
|
||||
public GameSettings Settings => settings;
|
||||
|
||||
[ShowInInspector]
|
||||
[ReadOnly]
|
||||
[BoxGroup("Runtime")]
|
||||
private bool IsActiveInstance => Instance == this;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance == null)
|
||||
{
|
||||
Instance = this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
|
||||
if (settings == null)
|
||||
{
|
||||
// Fallback or load from Resources if needed
|
||||
settings = ScriptableObject.CreateInstance<GameSettings>();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetSensitivity(float value)
|
||||
{
|
||||
settings.sensitivity = value;
|
||||
OnSettingsChanged?.Invoke();
|
||||
}
|
||||
|
||||
public void SetInvertX(bool value)
|
||||
{
|
||||
settings.invertX = value;
|
||||
OnSettingsChanged?.Invoke();
|
||||
}
|
||||
|
||||
public void SetInvertY(bool value)
|
||||
{
|
||||
settings.invertY = value;
|
||||
OnSettingsChanged?.Invoke();
|
||||
}
|
||||
|
||||
public void SetSideBias(bool isRight)
|
||||
{
|
||||
settings.sideBiasRight = isRight;
|
||||
OnSettingsChanged?.Invoke();
|
||||
}
|
||||
|
||||
public void ToggleSideBias()
|
||||
{
|
||||
settings.sideBiasRight = !settings.sideBiasRight;
|
||||
OnSettingsChanged?.Invoke();
|
||||
}
|
||||
|
||||
[Button("Notify Settings Changed")]
|
||||
private void NotifySettingsChanged()
|
||||
{
|
||||
OnSettingsChanged?.Invoke();
|
||||
}
|
||||
|
||||
public event System.Action OnSettingsChanged;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user