Apologies upfront - I’m still learning Unity and C# and this is my first proper project where I’m not following any kind of tutorial… This is also my first question on here, so sorry if I’ve gone about this incorrectly!
I have a system in my game that generates levels and saves them into a series of arrays. When the game is run on a Windows machine, I include that save file with the game and deserialise it as follows:
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Open(Path.Combine(Application.streamingAssetsPath,"levelsetup.gd"), FileMode.Open);
SaveLoad load = (SaveLoad)bf.Deserialize(file);
file.Close();
availableLevels = load.availableLevels;
levelSetup = load.levelSetup;
planetType = load.planetType;
planetXCoordinates = load.planetXCoordinates;
planetYCoordinates = load.planetYCoordinates;
planetScale = load.planetScale;
Debug.Log("File loaded");
…which might not be the most efficient way of doing this, but it all runs swimmingly. I can generate new levels within Unity and save them out and then the game loads them up when I run a build. All good.
However, I can’t find a way of doing anything similar for my WebGL build. The documentation for the StreamingAssets functionality suggests that WebGL doesn’t support it and says to use a UnityWebRequest, but that page doesn’t really explain how anything works or provide any good examples.
Any thoughts on how I can do this, or on where I can find a decent explanation for UnityWebRequest?