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 /
avatar image
0
Question by PeroChield · Apr 30, 2018 at 02:58 PM · uijsonscript error

I don't understand how save to QualitySettings.SetQuality with a json file

I want someone to fix what I've sent and thank you. There is my SettingsManager script:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 using System.IO;
 
 public class SettingsManager : MonoBehaviour {
 
     public Dropdown textureQualityDropdown;
     public GameSettings gameSettings;
     public Button applyButton;
 
     void OnEnable()
     {
         textureQualityDropdown.onValueChanged.AddListener(delegate {
 OnTextureQualityDrowpon(); });
         applyButton.onClick.AddListener(delegate { OnApplyButtonClick(); });
         LoadSettings();
     }
     public void OnTextureQualityDrowpon()
     {
         QualitySettings.SetQualityLevel (gameSettings.textureQuality = textureQualityDropdown.value);
     }
     public void OnApplyButtonClick()
     {
         SaveSettings();
     }
     public void SaveSettings()
     {
     public void SaveSettings()
     {
         string jsonData = JsonUtility.ToJson(gameSettings, true);
         File.WriteAllText(Application.persistentDataPath + "/gamesettings.json", jsonData);
     }
  public void LoadSettings()
     {
         File.ReadAllText(Application.persistentDataPath + "/gamesettings.json");
         gameSettings = JsonUtility.FromJson<GameSettings>(File.ReadAllText(Application.persistentDataPath + "/gamesettings.json"));
         textureQualityDropdown.value = gameSettings.textureQuality;
   }
 }

And other is my GameSettings script:

 public class GameSettings{
 
   public int textureQuality;
 
     }

I have another question to ask about how to setup a slider and an input field to takes value ? Thank you for your answers. Because I'm started a Unity program 3 weeks ago.

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
1
Best Answer

Answer by SharkoFR · Apr 30, 2018 at 05:10 PM

Hi!

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using System.IO;           /// ADD THIS
 
 public class tuto : MonoBehaviour {
 
     public void saveSettings()                                                                                  
     {
         string jsonData = JsonUtility.ToJson(gameSettings, true);
         using (StreamWriter sr = new StreamWriter(Application.persistentDataPath + @"/gamesettings.json"))
         {
             sr.WriteLine(jsonData);
         }
     }
 
 }
 

add using System.IO; and the lines i gived to you, i answer later for your second question

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 PeroChield · Apr 30, 2018 at 06:19 PM 0
Share

sorry I did not pay attention to what I wrote! Should i type it that

        QualitySettings.SetQualityLevel (gameSettings.textureQuality = textureQualityDropdown.value);

ins$$anonymous$$d of

        QualitySettings.SetQualityLevel() =gameSettings.textureQuality = textureQualityDropdown.value;

but I've tried this and it did not work.... Thank you for answer!

avatar image SharkoFR PeroChield · May 01, 2018 at 12:14 PM 0
Share

For slider there are few videos on youtube, it's very simple!

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

140 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

Related Questions

How to create vertical scroll inside horizontal scroll? 1 Answer

Parseing JTokens 0 Answers

Binding JSON contents to ui sliders 0 Answers

a live updating button panel? pulling from an external api? 0 Answers

Trying to get a text line to string from txt file 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