-1

I would like to create a system where a player/ user click on a button to save and download a Json file listing the name and position of game objects in a Unity WebGL scene. I am able to write the Json file with the required content in the editor. But I dont know How can I do it in WebGL. I was reading about .jslb plugins. But couldnt figure out how I can write one for my requirement.

Many thanks in Advance! :)

yousufali.n
  • 21
  • 2
  • 10
  • Download from where? Save where? Sounds strange to first save and the download a file .. wouldn't it be the other way round? – derHugo Dec 23 '20 at 11:39
  • Hi, Saving the gameobject name and positions to a Json file from the Webgl build and then download it to the local device. :) – yousufali.n Dec 23 '20 at 11:46
  • You looked at e.g. [this plugin](https://github.com/nateonusapps/WebGLFileSaverForUnity)? Currently your question is too broad .. try to solve one problem at a time .. are you asking how to create a JSON file or are you asking how to store a file from WebGL to the local device? ;) – derHugo Dec 23 '20 at 13:19
  • Thank you for the Plugin link! Shall go through it. I managed to create a Json with the necessary game data. `saveContent[] sc = new saveContent[objName.Count];` . . `string json = JsonHelper.ToJson(sc,true);` I would like to create a button now that will allow the user to download the created Json file. I am totally beginner to Unity and C#, so learning things by doing :) – yousufali.n Dec 23 '20 at 13:35

1 Answers1

0

I found this nice File browser plugin that basically allowing me to do more or less everything that I was looking for. :) The Github repo also got a nice documentation!

yousufali.n
  • 21
  • 2
  • 10
  • Note that the linked plugin is mainly for standalone (windows/Linux/Mac) and explicitly states for WebGL `Not well tested, probably not much reliable.` – derHugo Jun 15 '22 at 13:27