Search Unity

Is there a way to change settings AFTER build ?

Discussion in 'Web' started by Jichaels, Feb 18, 2019.

  1. Jichaels

    Jichaels

    Joined:
    Dec 27, 2018
    Posts:
    237
    Hello,

    I'm currently working on a small project for myself (a multiplayer space shooter) and everything is working well in windows standalone build aswell as unity editor. I have a json file that I use to load settings at startup. So if I need to make a few changes in settings I only have to edit the json file instead of rebuilding everything.

    How can I achieve the same for WebGL ? I already have a #if UNITY_WEBGL block but currently it's hardcoded and if I want to change something I need to rebuild for WebGL (and it's taking soooooo long it's insane).

    Anyhelp would help me a ton (and my processor too, he's dying when I build to WebGL :D)
     
  2. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    What's preventing you to use the json settings file on WebGL?
     
  3. Jichaels

    Jichaels

    Joined:
    Dec 27, 2018
    Posts:
    237
    For standalone build I use relative path (aka. Application.dataPath + "/Config/myfile) and create a folder Config in MyApp/MyApp_data, but when building to WebGL Application.dataPath gives an url instead of the path to the app.

    Thanks for your answer anyway !
     
  4. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    I would suggest to start by having your config file in Assets/StreamingAssets/Config, then download the file at run-time using UnityWebRequest. The url will be the following:

    Code (csharp):
    1. Application.streamingAssetsPath + "/Config/myfile

    Have a look at this page for more info on the StreamingAssets directory.
     
  5. Jichaels

    Jichaels

    Joined:
    Dec 27, 2018
    Posts:
    237
    Thanks a ton, I completly missed that ! I had to copy/paste my config folder every time I built the project.
    I'll see what I can do for WebGL !

    Thanks again
     
  6. Jichaels

    Jichaels

    Joined:
    Dec 27, 2018
    Posts:
    237
    Everything working like a charm in editor, standalone and WebGL :D