SOME slider don't accept SOME variables... WHY???
Hello everyone. I have a truly strange problem. It looks like I'm doing something obviously wrong, but I cannot find how! I pretty much finished my game, and while creating the main menu, I came across a strange problem: 2 sliders don't get the value when I assign it. You can see there are some print, then i assign values, and then print again, because I found there that when I assign variables sliderAntialiasing and sliderSuoni don't get it, the others do. To make everything more strange, not only sliderSuoni in the UI is a copy of sliderMusica, and sliderMusica works, but if I assign every other variable to those 2 they get it! For example trying to give sliderAntialiasing the value of qualitaAttuale, since it is still in the slider value range it obviously works, and the same with sliderSuoni, it gets it if I assign the value volumeMusica, but not the one I need volumeSuoni, plus, sliderMusica gets correctly volumeSuoni. So with the prints I can see that the variables are loaded and saved correctly, since when I change them and restart the game they are loaded as I modified them, but then after assigning to the sliders their values I check the sliders' values and every other but those 2 works, they just stay as I put them in the editor.
All of this is pretty confusing, but it looks like a super-easy thing to figure out, maybe I don't see the obvious problem because I read it too many times.
Only note here is that sliderAntialiasing is whole numbers only, that's why it's int, but I tried make the variable float and nothing changed.
public GameObject menuMain;
public GameObject credits;
public GameObject opzioni;
public GameObject opzioniGrafiche;
public GameObject opzioniAudio;
public Light sole;
public Texture2D toniGiornata;
private int oraDelGiorno;
public PostProcessingProfile profiloPostProcessing;
private AntialiasingModel.Settings datiAliasing;
public Dropdown dropDownGrafica;
private int qualitaAttuale;
public Toggle toggleBloom;
private int bloomAttivo;
public Slider sliderAntialiasing;
private int livelloAliasing;
public Slider sliderMusica;
private float volumeMusica;
public Slider sliderSuoni;
private float volumeSuoni;
public Button tastoStart;
public AudioSource suoni;
public AudioClip click;
public AudioClip retry;
public AudioSource colonnaSonora;
private void Start()
{
credits.SetActive(false);
opzioni.SetActive(false);
opzioniGrafiche.SetActive(false);
opzioniAudio.SetActive(false);
Cursor.visible = true;
if (PlayerPrefs.HasKey("Qualita"))
{
qualitaAttuale = PlayerPrefs.GetInt("Qualita");
}
else
{
qualitaAttuale = 3;
PlayerPrefs.SetInt("Qualita", qualitaAttuale);
}
if (PlayerPrefs.HasKey("Bloom"))
{
bloomAttivo = PlayerPrefs.GetInt("Bloom");
}
else
{
bloomAttivo = 1;
PlayerPrefs.SetInt("Bloom", bloomAttivo);
}
if (PlayerPrefs.HasKey("Antialiasing"))
{
livelloAliasing = PlayerPrefs.GetInt("Antialiasing");
}
else
{
livelloAliasing = 2;
PlayerPrefs.SetInt("Antialiasing", livelloAliasing);
}
if (PlayerPrefs.HasKey("VolumeMusica"))
{
volumeMusica = PlayerPrefs.GetFloat("VolumeMusica");
}
else
{
volumeMusica = 1;
PlayerPrefs.SetFloat("VolumeMusica", volumeMusica);
}
if (PlayerPrefs.HasKey("VolumeSuoni"))
{
volumeSuoni = PlayerPrefs.GetFloat("VolumeSuoni");
}
else
{
volumeSuoni = 1;
PlayerPrefs.SetFloat("VolumeSuoni", volumeSuoni);
}
datiAliasing = profiloPostProcessing.antialiasing.settings;
print("alias" + livelloAliasing);
print("musica" + volumeMusica);
print("suoni" + volumeSuoni);
dropDownGrafica.value = qualitaAttuale - 2;
sliderAntialiasing.value = livelloAliasing;
sliderMusica.value = volumeMusica;
sliderSuoni.value = volumeSuoni;
print(sliderAntialiasing.value);
print(sliderMusica.value);
print(sliderSuoni.value);
if (bloomAttivo == 1)
{
toggleBloom.isOn = true;
}
else
{
toggleBloom.isOn = false;
}
oraDelGiorno = System.DateTime.Now.Hour;
sole.color = toniGiornata.GetPixel(oraDelGiorno, 1);
RenderSettings.skybox.SetColor("_Tint", toniGiornata.GetPixel(oraDelGiorno, 0));
}
Your answer
Follow this Question
Related Questions
Can jump even when in the air. 0 Answers
Changing script variable from another script doesn't change it in the original script? 0 Answers
Check transform changes on multiple GameObjects / re-instantiate script on existing GameObject 0 Answers
OnTriggerEnter2D tiggers twice 0 Answers
Why is Unity showing the wrong variables in the Inspector? 1 Answer