Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
avatar image
0
Question by imagoculturae · Sep 27, 2018 at 02:21 PM · slider

Slider position does not update when value is loaded

Hi can't make this to work: Basically I am try to change the value of a slider when I load some value that I previously saved. I have tested the data and it works fine when reading it (the value is what is supposed to be) just does not update the position of the slider :-( Please help!

     public void Load()
             {
                 if (File.Exists(Application.persistentDataPath + "/weatherInfo.dat"))
                 {
                     BinaryFormatter bf = new BinaryFormatter();
                     FileStream file = File.Open(Application.persistentDataPath + "/weatherInfo.dat", FileMode.Open);
 
                     WeatherData data = bf.Deserialize(file) as WeatherData;
                     file.Close();
 
                     DawnDuskSlider.value = data.hours;
                     
                     Debug.Log("data in data is:" + data.hours);
                     Debug.Log("data in slider is:" + DawnDuskSlider.value);
                     
                 }
             }
 
 
 

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by KittenSnipes · Sep 29, 2018 at 09:19 AM

@paganic I think it is because you close the file and thus lost the data that it was holding temporarily. Try writing it like this instead:

              public void Load()
              {
                  if (File.Exists(Application.persistentDataPath + "/weatherInfo.dat"))
                  {
                      BinaryFormatter bf = new BinaryFormatter();
                      FileStream file = File.Open(Application.persistentDataPath + "/weatherInfo.dat", FileMode.Open);
  
                      WeatherData data = bf.Deserialize(file) as WeatherData;
  
                      DawnDuskSlider.value = data.hours;
                      file.Close();
                   }
              }
Comment
Add comment · Show 2 · Share
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
avatar image imagoculturae · Sep 30, 2018 at 12:12 AM 0
Share

Nop... the slider still does not move :-(

I have also tried this but no luck when calling the function so that value is set and ok but slider does not move:

       public void SubmitSliderSetting(float slide)
             {
                 DawnDuskSlider.value = slide;
                 //Displays the value of the slider in the console.
                 Debug.Log(DawnDuskSlider.value);
             }
 




avatar image imagoculturae · Oct 02, 2018 at 01:01 PM 0
Share

I think is a bug in Unity because I have also try this and it does not work:

  public void SaveSettings()
         {
             PlayerPrefs.SetFloat("Hours", DawnDuskSlider.value);
 
             Debug.Log("data out slider is:" + DawnDuskSlider.value);
         }
 
         public void LoadSettings(float val)
         {
             
             DawnDuskSlider.value = PlayerPrefs.GetFloat("Hours", val);
             Debug.Log("data in slider is:" + DawnDuskSlider.value);
         }
 


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

92 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

Related Questions

GUI slider and rotation not working 1 Answer

ScrollView performances with huge number of GUIContents. 2 Answers

Change text colour in game using the colour spectrum. 3 Answers

move object with slider 1 Answer

How do i use a slider to adjust Brightness or Contrast? 3 Answers


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