Script de configurações não esta funcionando corretamente
Página 1 de 1
Script de configurações não esta funcionando corretamente
Boa noite!
Possuo este script:
Possuo este script:
- Código:
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.UI;
public class NewSettings : MonoBehaviour
{
public AudioMixer audioMixer;
public Dropdown resolutionDropdown;
public Dropdown qualityDropdown;
public Dropdown textureDropdown;
public Dropdown aaDropdown;
public Slider volumeSlider;
float currentVolume;
Resolution[] resolutions;
// Start is called before the first frame update
void Start()
{
resolutionDropdown.ClearOptions();
List<string> options = new List<string>();
resolutions = Screen.resolutions;
int currentResolutionIndex = 0;
for (int i = 0; i < resolutions.Length; i++)
{
string option = resolutions[i].width + "x" + resolutions[i].height;
options.Add(option);
if (resolutions[i].width == Screen.currentResolution.width
&& resolutions[i].height == Screen.currentResolution.height)
currentResolutionIndex = i;
}
resolutionDropdown.AddOptions(options);
resolutionDropdown.RefreshShownValue();
LoadSettings(currentResolutionIndex);
}
public void SetVolume(float volume)
{
audioMixer.SetFloat("Volume", volume);
currentVolume = volume;
}
public void SetFullscreen(bool isFullscreen)
{
ControlFreak2.CFScreen.fullScreen = isFullscreen;
}
public void SetResolution(int resolutionIndex)
{
Resolution resolution = resolutions[resolutionIndex];
Screen.SetResolution(resolution.width,
resolution.height, ControlFreak2.CFScreen.fullScreen);
}
public void SetTextureQuality(int textureIndex)
{
QualitySettings.masterTextureLimit = textureIndex;
qualityDropdown.value = 6;
}
public void SetAntiAliasing(int aaIndex)
{
QualitySettings.antiAliasing = aaIndex;
qualityDropdown.value = 6;
}
public void SetQuality(int qualityIndex)
{
if (qualityIndex != 6) // if the user is not using
//any of the presets
QualitySettings.SetQualityLevel(qualityIndex);
switch (qualityIndex)
{
case 0: // quality level - very low
textureDropdown.value = 3;
aaDropdown.value = 0;
break;
case 1: // quality level - low
textureDropdown.value = 2;
aaDropdown.value = 0;
break;
case 2: // quality level - medium
textureDropdown.value = 1;
aaDropdown.value = 0;
break;
case 3: // quality level - high
textureDropdown.value = 0;
aaDropdown.value = 0;
break;
case 4: // quality level - very high
textureDropdown.value = 0;
aaDropdown.value = 1;
break;
case 5: // quality level - ultra
textureDropdown.value = 0;
aaDropdown.value = 2;
break;
}
qualityDropdown.value = qualityIndex;
}
public void SaveSettings()
{
PlayerPrefs.SetInt("QualitySettingPreference",
qualityDropdown.value);
PlayerPrefs.SetInt("ResolutionPreference",
resolutionDropdown.value);
PlayerPrefs.SetInt("TextureQualityPreference",
textureDropdown.value);
PlayerPrefs.SetInt("AntiAliasingPreference",
aaDropdown.value);
PlayerPrefs.SetInt("FullscreenPreference",
Convert.ToInt32(ControlFreak2.CFScreen.fullScreen));
PlayerPrefs.SetFloat("VolumePreference",
currentVolume);
}
public void LoadSettings(int currentResolutionIndex)
{
if (PlayerPrefs.HasKey("QualitySettingPreference"))
qualityDropdown.value =
PlayerPrefs.GetInt("QualitySettingPreference");
else
qualityDropdown.value = 3;
if (PlayerPrefs.HasKey("ResolutionPreference"))
resolutionDropdown.value =
PlayerPrefs.GetInt("ResolutionPreference");
else
resolutionDropdown.value = currentResolutionIndex;
if (PlayerPrefs.HasKey("TextureQualityPreference"))
textureDropdown.value =
PlayerPrefs.GetInt("TextureQualityPreference");
else
textureDropdown.value = 0;
if (PlayerPrefs.HasKey("AntiAliasingPreference"))
aaDropdown.value =
PlayerPrefs.GetInt("AntiAliasingPreference");
else
aaDropdown.value = 1;
if (PlayerPrefs.HasKey("FullscreenPreference"))
ControlFreak2.CFScreen.fullScreen =
Convert.ToBoolean(PlayerPrefs.GetInt("FullscreenPreference"));
else
ControlFreak2.CFScreen.fullScreen = true;
if (PlayerPrefs.HasKey("VolumePreference"))
volumeSlider.value =
PlayerPrefs.GetFloat("VolumePreference");
else
volumeSlider.value =
PlayerPrefs.GetFloat("VolumePreference");
}
public void ExitGame()
{
Application.Quit();
}
}
Tópicos semelhantes
» Fiz um script mas não está funcionando corretamente. Alguém pode me ajudar?
» botoes não esta funcionando corretamente nem a fisica?
» Script de movimentação e câmera não executa corretamente
» Oq esta de errado com esse script?
» [RESOLVIDO] Script não funciona corretamente, qual seria o problema?
» botoes não esta funcionando corretamente nem a fisica?
» Script de movimentação e câmera não executa corretamente
» Oq esta de errado com esse script?
» [RESOLVIDO] Script não funciona corretamente, qual seria o problema?
Página 1 de 1
Permissões neste sub-fórum
Não podes responder a tópicos