59 lines
1.8 KiB
C#
59 lines
1.8 KiB
C#
using TMPro;
|
|
using UnityEngine;
|
|
using System.Collections.Generic;
|
|
using UnityEngine.Rendering.PostProcessing;
|
|
|
|
public class SettingsPanel : MonoBehaviour
|
|
{
|
|
public GameObject settingsPanel;
|
|
public GameObject settingsPanelDeactivator;
|
|
public bool DisableSettingsPanelWhenLinkedGameobjectIsActivated = false;
|
|
public TMP_Dropdown GraphicsQualityDropdown;
|
|
public PostProcessVolume PostProcessVolume;
|
|
public List<PostProcessVolume> PostProcessingVolumes = new() { };
|
|
|
|
private void Update()
|
|
{
|
|
if (settingsPanel && DisableSettingsPanelWhenLinkedGameobjectIsActivated && settingsPanelDeactivator.activeInHierarchy)
|
|
{
|
|
settingsPanel.SetActive(false);
|
|
settingsPanelDeactivator.SetActive(false);
|
|
}
|
|
}
|
|
|
|
public void AcTogglePostProcessing(bool IsEnabled) {
|
|
if (IsEnabled)
|
|
PlayerPrefs.SetInt("PostProcessingEnabled", 1);
|
|
else
|
|
PlayerPrefs.SetInt("PostProcessingEnabled", 0);
|
|
|
|
foreach (PostProcessVolume volume in PostProcessingVolumes)
|
|
volume.enabled = IsEnabled;
|
|
}
|
|
|
|
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);
|
|
GraphicsQualityDropdown.value = QualitySettings.GetQualityLevel();
|
|
}
|
|
}
|
|
|
|
public void SwitchQualitySettings(int index)
|
|
{
|
|
if (GraphicsQualityDropdown)
|
|
{
|
|
QualitySettings.SetQualityLevel(index);
|
|
}
|
|
}
|
|
}
|