Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Numisi · Jan 11, 2018 at 04:16 PM · scripting problembug-perhaps

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));
     }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

174 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges