Danro/Assets/Scripts/Settings/Core/SettingsButtonActions.cs
Danil Iarosh 009152ac5b
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
Added ValueSelectorRow option to int settings
- Добавил новый тип отображения настроек с целочисленным значением
- У этого типа можно настраивать шаг, выглядит приятнее
2026-02-06 16:14:39 +03:00

110 lines
2.9 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using UnityEngine;
using UnityEngine.SceneManagement;
namespace RR.Common.Settings
{
/// <summary>
/// Готовые методы для кнопок настроек.
/// Эти методы можно вызывать из UnityEvent в SettingsDatabase через Inspector.
/// </summary>
public class SettingsButtonActions : MonoBehaviour
{
public static SettingsButtonActions Instance { get; private set; }
private void Awake()
{
if (Instance == null)
{
Instance = this;
DontDestroyOnLoad(gameObject);
}
else
{
Destroy(gameObject);
}
}
/// <summary>
/// Сбросить все настройки к значениям по умолчанию
/// </summary>
public void ResetAllSettings()
{
if (SettingsManager.Instance)
{
SettingsManager.Instance.ResetAllToDefaults();
}
}
/// <summary>
/// Выход из игры
/// </summary>
public void QuitGame()
{
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
}
/// <summary>
/// Загрузить главное меню
/// </summary>
public void LoadMainMenu()
{
LoadScene("MainMenu");
}
/// <summary>
/// Загрузить сцену по имени
/// </summary>
public void LoadScene(string sceneName)
{
if (!string.IsNullOrEmpty(sceneName))
{
SceneManager.LoadScene(sceneName);
}
}
/// <summary>
/// Открыть URL в браузере
/// </summary>
public void OpenURL(string url)
{
if (!string.IsNullOrEmpty(url))
{
Application.OpenURL(url);
}
}
/// <summary>
/// Открыть папку с сохранениями
/// </summary>
public void OpenSavesFolder()
{
string path = Application.persistentDataPath;
Application.OpenURL($"file://{path}");
}
/// <summary>
/// Перезагрузить текущую сцену
/// </summary>
public void ReloadCurrentScene()
{
Scene currentScene = SceneManager.GetActiveScene();
SceneManager.LoadScene(currentScene.name);
}
/// <summary>
/// Применить все настройки заново
/// </summary>
public void ApplyAllSettings()
{
if (SettingsManager.Instance)
{
SettingsManager.Instance.ApplyAll();
}
}
}
}