2024-01-27 08:49:55 +08:00
|
|
|
using TMPro;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine.Rendering.PostProcessing;
|
2024-02-04 17:52:19 +08:00
|
|
|
using UnityEngine.UI;
|
2024-01-27 08:49:55 +08:00
|
|
|
|
|
|
|
|
public class SettingsPanel : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public GameObject settingsPanel;
|
|
|
|
|
public GameObject settingsPanelDeactivator;
|
|
|
|
|
public bool DisableSettingsPanelWhenLinkedGameobjectIsActivated = false;
|
|
|
|
|
public TMP_Dropdown GraphicsQualityDropdown;
|
2024-02-04 17:52:19 +08:00
|
|
|
public Toggle FullscreenToggle;
|
2024-01-27 08:49:55 +08:00
|
|
|
public PostProcessVolume PostProcessVolume;
|
2024-01-31 22:53:00 +08:00
|
|
|
public List<PostProcessVolume> PostProcessingVolumes = new() { };
|
|
|
|
|
|
2024-01-27 08:49:55 +08:00
|
|
|
private void Update()
|
|
|
|
|
{
|
|
|
|
|
if (settingsPanel && DisableSettingsPanelWhenLinkedGameobjectIsActivated && settingsPanelDeactivator.activeInHierarchy)
|
|
|
|
|
{
|
|
|
|
|
settingsPanel.SetActive(false);
|
|
|
|
|
settingsPanelDeactivator.SetActive(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-31 22:53:00 +08:00
|
|
|
public void AcTogglePostProcessing(bool IsEnabled) {
|
|
|
|
|
if (IsEnabled)
|
|
|
|
|
PlayerPrefs.SetInt("PostProcessingEnabled", 1);
|
|
|
|
|
else
|
|
|
|
|
PlayerPrefs.SetInt("PostProcessingEnabled", 0);
|
|
|
|
|
|
|
|
|
|
foreach (PostProcessVolume volume in PostProcessingVolumes)
|
|
|
|
|
volume.enabled = IsEnabled;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-27 08:49:55 +08:00
|
|
|
private void Start()
|
|
|
|
|
{
|
|
|
|
|
if (GraphicsQualityDropdown)
|
|
|
|
|
{
|
|
|
|
|
string[] QualityNames = QualitySettings.names;
|
|
|
|
|
List<TMP_Dropdown.OptionData> Options = new();
|
|
|
|
|
GraphicsQualityDropdown.ClearOptions();
|
|
|
|
|
foreach (string QualityName in QualityNames)
|
|
|
|
|
{
|
|
|
|
|
Options.Add(new TMP_Dropdown.OptionData(QualityName));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GraphicsQualityDropdown.AddOptions(Options);
|
2024-02-04 17:52:19 +08:00
|
|
|
if (!PlayerPrefs.HasKey("QualityLevel"))
|
|
|
|
|
GraphicsQualityDropdown.value = QualitySettings.GetQualityLevel();
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
QualitySettings.SetQualityLevel(PlayerPrefs.GetInt("QualityLevel"));
|
|
|
|
|
GraphicsQualityDropdown.value = PlayerPrefs.GetInt("QualityLevel");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (PlayerPrefs.HasKey("FullscreenState") && FullscreenToggle)
|
|
|
|
|
{
|
|
|
|
|
FullscreenToggle.isOn = bool.Parse(PlayerPrefs.GetString("FullscreenState"));
|
|
|
|
|
}
|
2024-01-27 08:49:55 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SwitchQualitySettings(int index)
|
|
|
|
|
{
|
|
|
|
|
if (GraphicsQualityDropdown)
|
|
|
|
|
{
|
2024-02-04 17:52:19 +08:00
|
|
|
PlayerPrefs.SetInt("QualityLevel", index);
|
2024-01-27 08:49:55 +08:00
|
|
|
QualitySettings.SetQualityLevel(index);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|