Первый коммит с LFS.

This commit is contained in:
vladislove committed 2026-01-11 17:04:23 +03:00
1 parent 4fcb1e2f24
commit 179816dc4b
5084 files changed
+3714098 -1

No files matched your search

+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: cb8c2949fea711db684d48e39a5532bb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,34 @@
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal; // Assuming URP. Change if using built-in or HDRP.
public class BrightnessController : MonoBehaviour
{
[SerializeField] private Volume postProcessVolume;
private ColorAdjustments colorAdjustments;
private void Start()
{
if (postProcessVolume != null && postProcessVolume.profile.TryGet(out colorAdjustments))
{
// Successfully found the ColorAdjustments effect
}
else
{
Debug.LogError("BrightnessController could not find a Volume with ColorAdjustments.", this);
}
}
/// <summary>
/// Sets the brightness.
/// </summary>
/// <param name="value">A value from 0 (dark) to 1 (bright).</param>
public void SetBrightness(float value)
{
if (colorAdjustments != null)
{
// We map the 0-1 slider value to a new exposure range, e.g., -1 to 1.4.
colorAdjustments.postExposure.value = Mathf.Lerp(-1f, 1.4f, value);
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: b6cf8da173c032576826c0f5c7c6c2d3
+89
View File
@@ -0,0 +1,89 @@
using Player;
using UnityEngine;
public class PauseMenuController : MonoBehaviour
{
[Header("References")]
[SerializeField] private GameObject pauseMenuPanel;
[SerializeField] private GameObject settingsPanel;
[SerializeField] private PlayerController playerController;
private bool isPaused = false;
private void Start()
{
pauseMenuPanel.SetActive(false);
settingsPanel.SetActive(false);
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
// If settings are open, the first Escape press should close them
if (settingsPanel.activeSelf)
{
CloseSettings();
}
// If only the pause menu is open, Escape should resume the game
else if (isPaused)
{
ResumeGame();
}
// If not paused, Escape should pause the game
else
{
PauseGame();
}
}
}
public void PauseGame()
{
isPaused = true;
Time.timeScale = 0f;
pauseMenuPanel.SetActive(true);
settingsPanel.SetActive(false); // Ensure settings are closed initially
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
if (playerController != null) playerController.inputLocked = true;
}
public void ResumeGame()
{
isPaused = false;
Time.timeScale = 1f;
pauseMenuPanel.SetActive(false);
settingsPanel.SetActive(false);
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
if (playerController != null) playerController.inputLocked = false;
}
// --- Button Methods ---
public void OnResumeButtonClicked()
{
ResumeGame();
}
public void OpenSettings()
{
pauseMenuPanel.SetActive(false);
settingsPanel.SetActive(true);
}
public void CloseSettings()
{
settingsPanel.SetActive(false);
pauseMenuPanel.SetActive(true);
}
public void OnExitButtonClicked()
{
Debug.Log("Exiting application...");
Application.Quit();
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 95db6f9ba8e660f888fba379bde35163
+134
View File
@@ -0,0 +1,134 @@
using Player;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Audio;
using TMPro;
public class SettingsManager : MonoBehaviour
{
[Header("Audio")]
[SerializeField] private AudioMixer mainMixer;
[SerializeField] private Slider masterVolumeSlider;
[Header("Sensitivity")]
[SerializeField] private Slider sensitivitySlider;
[SerializeField] private TMP_InputField sensitivityInputField;
[SerializeField] private PlayerController playerController;
[Header("Brightness")]
[SerializeField] private Slider brightnessSlider;
[SerializeField] private BrightnessController brightnessController;
// PlayerPrefs Keys
private const string MASTER_VOLUME_KEY = "MasterVolume";
private const string SENSITIVITY_KEY = "MouseSensitivity";
private const string BRIGHTNESS_KEY = "ScreenBrightness";
private void Start()
{
// First, load all saved values and apply them WITHOUT triggering events.
LoadInitialValues();
// NOW, after everything is set up, subscribe to user-driven changes.
SubscribeToEvents();
}
private void LoadInitialValues()
{
// --- Volume ---
float masterVolume = PlayerPrefs.GetFloat(MASTER_VOLUME_KEY, 0.75f);
masterVolumeSlider.SetValueWithoutNotify(masterVolume); // Use WithoutNotify to prevent event firing
ApplyMasterVolume(masterVolume);
// --- Sensitivity ---
float maxSensitivity = sensitivitySlider.maxValue;
float sensitivity = PlayerPrefs.GetFloat(SENSITIVITY_KEY, maxSensitivity / 2);
sensitivitySlider.SetValueWithoutNotify(sensitivity);
sensitivityInputField.SetTextWithoutNotify(sensitivity.ToString("F1")); // Use WithoutNotify
ApplySensitivity(sensitivity);
// --- Brightness ---
float brightness = PlayerPrefs.GetFloat(BRIGHTNESS_KEY, 0.5f);
brightnessSlider.SetValueWithoutNotify(brightness);
ApplyBrightness(brightness);
}
private void SubscribeToEvents()
{
masterVolumeSlider.onValueChanged.AddListener(OnMasterVolumeChanged);
sensitivitySlider.onValueChanged.AddListener(OnSensitivitySliderChanged);
sensitivityInputField.onEndEdit.AddListener(OnSensitivityInputChanged);
brightnessSlider.onValueChanged.AddListener(OnBrightnessChanged);
}
// --- Event Handlers ---
private void OnMasterVolumeChanged(float value)
{
ApplyMasterVolume(value);
PlayerPrefs.SetFloat(MASTER_VOLUME_KEY, value);
}
private void OnSensitivitySliderChanged(float value)
{
sensitivityInputField.SetTextWithoutNotify(value.ToString("F1"));
ApplySensitivity(value);
PlayerPrefs.SetFloat(SENSITIVITY_KEY, value);
}
private void OnSensitivityInputChanged(string textValue)
{
if (float.TryParse(textValue, out float value))
{
value = Mathf.Clamp(value, sensitivitySlider.minValue, sensitivitySlider.maxValue);
sensitivitySlider.SetValueWithoutNotify(value); // This will NOT trigger the slider's event
ApplySensitivity(value); // So we must apply the change manually
PlayerPrefs.SetFloat(SENSITIVITY_KEY, value);
}
else
{
sensitivityInputField.SetTextWithoutNotify(sensitivitySlider.value.ToString("F1"));
}
}
private void OnBrightnessChanged(float value)
{
ApplyBrightness(value);
PlayerPrefs.SetFloat(BRIGHTNESS_KEY, value);
}
// --- Apply Logic ---
private void ApplyMasterVolume(float value)
{
if (mainMixer == null) return;
// Use a small epsilon to prevent Log10(0) = -Infinity
float dbValue = Mathf.Log10(Mathf.Max(value, 0.0001f)) * 20;
mainMixer.SetFloat("MasterVolume", dbValue);
}
private void ApplySensitivity(float value)
{
if (playerController != null)
{
playerController.mouseSensitivity = value;
}
}
private void ApplyBrightness(float value)
{
if (brightnessController != null)
{
brightnessController.SetBrightness(value);
}
}
// Unsubscribe on destroy to prevent memory leaks
private void OnDestroy()
{
masterVolumeSlider?.onValueChanged.RemoveListener(OnMasterVolumeChanged);
sensitivitySlider?.onValueChanged.RemoveListener(OnSensitivitySliderChanged);
sensitivityInputField?.onEndEdit.RemoveListener(OnSensitivityInputChanged);
brightnessSlider?.onValueChanged.RemoveListener(OnBrightnessChanged);
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: bb5955905439ba64b8c2dd98e901f040