I have made assets saving in Streaming Assets by updating GetBasePath function in SaveSystem.cs script. It works perfectly for Windows build, same I require to work webGL, but it's not even the saved files there in StreamingAssets of WebGL build, where and all I need to change the path to streaming data for WebGL build from SreamingAssets. I have kept the generated json and dependent files in Streaming assets of WebGL build, data fetching and display not happening.

    8 days later

    benrajsd Hi! Sorry I don't understand your question, can you try to re-explain ? If english is not your language, can you try to use google translate?
    Can you also share your code ("SaveSystem.cs") ? so I can have a look.

    From webgl you can't save in a folder. You need to send your file to a webserver which will save the file for you. Same for reading.

      Anthony
      I have created a floor design and saved the date in streaming assets folder, want to consume that data for WebGL build.

      `using System;
      using System.Collections.Generic;
      using System.IO;
      using System.Text;
      using UnityEngine;

      namespace Exoa.Designer
      {
      public class SaveSystem
      {
      public enum Mode { FILE_SYSTEM, RESOURCES, ONLINE };
      public Mode mode;

          public static string defaultSubFolderName = null;
          public static string defaultFileToOpen = null;
          private string resourcesFolderLocation = "/Resources/";
      
          public string ResourcesFolderLocation { get => resourcesFolderLocation; set => resourcesFolderLocation = value; }
      
          public SaveSystem(Mode mode)
          {
              this.mode = mode;
          }
      
      
      
          [Serializable]
          public struct FileList
          {
              public List<string> list;
          }
          public static SaveSystem Create(Mode mode)
          {
              return new SaveSystem(mode);
          }
          public string GetBasePath(string subFolder)
          {
              string path = "";
              if (mode == Mode.RESOURCES)
              {
                  path = Application.dataPath;
              }
              else
              {
                  //path = Application.persistentDataPath + "/";

      #if UNITY_WEBGL
      path = Path.Combine(Application.streamingAssetsPath + "/");
      Debug.Log(path);

      #else
      path = Application.streamingAssetsPath + "/";
      #endif
      }

              if (!string.IsNullOrEmpty(subFolder))
                  path += subFolder + "/";
      
              try
              {
                  if (!Directory.Exists(path))
                      Directory.CreateDirectory(path);
              }
              catch (Exception e)
              {
                  Debug.LogError("Could not create folder:" + e.Message);
              }
              return path;
          }
          public void RefreshUnityDB()
          {

      #if UNITY_EDITOR
      UnityEditor.AssetDatabase.Refresh();
      #endif
      }
      public T LoadFileItem<T>(string fileName, string subFolderName, Action<T> pCallback = null, string ext = ".json")
      {
      Debug.Log("LoadFileItem " + subFolderName + "/" + fileName);
      HDLogger.Log("LoadFileItem " + subFolderName + "/" + fileName, HDLogger.LogCategory.FileSystem);

              string json = LoadFileItem(fileName, subFolderName, null, ext);
              T p = JsonUtility.FromJson<T>(json);
              pCallback?.Invoke(p);
              return p;
          }
          public string LoadFileItem(string fileName, string subFolderName, Action<string> pCallback = null, string ext = ".json")
          {
              Debug.Log("LoadFileItem " + GetBasePath(subFolderName) + "/" + fileName);
              HDLogger.Log("LoadFileItem " + GetBasePath(subFolderName) + "/" + fileName, HDLogger.LogCategory.FileSystem);
      
              string content = null;
      
              try
              {
                  if (mode == Mode.RESOURCES)
                  {
                      TextAsset o = Resources.Load<TextAsset>(subFolderName + "/" + fileName);
                      content = o != null ? o.text : null;
                  }
                  else
                  {
                      StreamReader stream = File.OpenText(GetBasePath(subFolderName) + fileName + ext);
                      content = stream.ReadToEnd();
                      stream.Close();
                  }
              }
              catch (System.Exception e)
              {
                  HDLogger.LogError("Error loading " + subFolderName + "/" + fileName + " " + e.Message, HDLogger.LogCategory.FileSystem);
                  AlertPopup.ShowAlert("error", "Error", "Error loading " + subFolderName + "/" + fileName + " " + e.Message);
              }
      
              if (!string.IsNullOrEmpty(content))
                  pCallback?.Invoke(content);
      
              return content;
          }
      
          public bool Exists(string fileName, string subFolderName, string ext = ".png")
          {
              bool exists = false;
              string path = null;
              if (mode == Mode.RESOURCES)
              {
                  path = subFolderName + "/" + fileName;
                  UnityEngine.Object o = Resources.Load(path);
                  exists = o != null;
              }
              else
              {

      #if UNITY_WEBGL
      path = Path.Combine(GetBasePath(subFolderName), fileName + ext);
      Debug.Log(path);
      #else
      path = GetBasePath(subFolderName) + fileName + ext;
      #endif
      exists = File.Exists(path);
      }
      HDLogger.Log("Exists " + path + " : " + exists, HDLogger.LogCategory.FileSystem);
      return exists;
      }

          public Texture2D LoadTextureItem(string fileName, string subFolderName, Action callback, string ext = ".png", int width = 100, int height = 100)
          {
              Debug.Log("LoadTextureItem " + fileName);
              HDLogger.Log("LoadTextureItem " + fileName, HDLogger.LogCategory.FileSystem);
              Texture2D tex = null;
      
              if (mode == Mode.RESOURCES)
              {
                  tex = Resources.Load<Texture2D>(subFolderName + "/" + fileName);
              }
              else
              {

      #if UNITY_WEBGL
      string path = Path.Combine(GetBasePath(subFolderName),fileName + ext);
      #else
      string path = GetBasePath(subFolderName) + fileName + ext;
      #endif

                  byte[] fileData;
      
                  if (File.Exists(path))
                  {
                      fileData = File.ReadAllBytes(path);
                      tex = new Texture2D(width, height);
                      tex.LoadImage(fileData);
      
                  }
              }
              return tex;
      
          }
      
          public void SaveFileItem(string fileName, string subFolderName, string json, Action<string> pCallback = null)
          {
              byte[] bytes = Encoding.ASCII.GetBytes(json);
              SaveFileItem(fileName, subFolderName, bytes, pCallback);
          }
          public void SaveFileItem(string fileName, string subFolderName, byte[] bytes, Action<string> pCallback = null)
          {
              if (bytes == null)
              {
                  HDLogger.LogWarning("Warning saving " + subFolderName + "/" + fileName + ", nothing to save (empty content)", HDLogger.LogCategory.FileSystem);
      
                  return;
              }
              HDLogger.Log("SaveFileItem " + GetBasePath(subFolderName) + fileName, HDLogger.LogCategory.FileSystem);
      
              bool success = false;
              try
              {
                  File.WriteAllBytes(GetBasePath(subFolderName) + fileName, bytes);
      
                  if (mode == Mode.RESOURCES)
                  {
                      RefreshUnityDB();
                  }
                  success = true;
              }
              catch (System.Exception e)
              {
                  HDLogger.LogError("Error saving " + subFolderName + "/" + fileName + " " + e.Message, HDLogger.LogCategory.FileSystem);
                  AlertPopup.ShowAlert("error", "Error", "Error loading " + subFolderName + "/" + fileName + " " + e.Message);
              }
      
              if (success)
                  pCallback?.Invoke(fileName);
      
          }
      
          public void DeleteFileItem(string fileName, string subFolderName, Action pCallback = null, string ext = ".json")
          {
              HDLogger.Log("DeleteFileItem " + fileName, HDLogger.LogCategory.FileSystem);
      
              try
              {
                  FileInfo fi = new FileInfo(GetBasePath(subFolderName) + fileName + ext);
                  fi.Delete();
      
                  pCallback?.Invoke();
              }
              catch (System.Exception e)
              {
                  HDLogger.LogError("Error deleting " + subFolderName + "/" + fileName + " " + e.Message, HDLogger.LogCategory.FileSystem);
                  AlertPopup.ShowAlert("error", "Error", e.Message);
              }
              RefreshUnityDB();
          }
      
          public void RenameFileItem(string fileName, string newName, string subFolderName, Action pCallback = null, string ext = ".json")
          {
              HDLogger.Log("RenameFileItem " + fileName + " " + newName, HDLogger.LogCategory.FileSystem);
      
              FileInfo fi = null;
              try
              {
                  fi = new FileInfo(GetBasePath(subFolderName) + fileName + ext);
                  fi.MoveTo(GetBasePath(subFolderName) + newName + ext);
      
                  pCallback?.Invoke();
              }
              catch (System.Exception e)
              {
                  AlertPopup.ShowAlert("error", "Error", e.Message);
                  HDLogger.LogError("Error renaming " + subFolderName + "/" + fileName + " " + e.Message, HDLogger.LogCategory.FileSystem);
              }
              RefreshUnityDB();
          }
      
          public void CopyFileItem(string fileName, string newName, string subFolderName, Action pCallback = null, string ext = ".json")
          {
              HDLogger.Log("CopyFileItem " + fileName + " " + newName, HDLogger.LogCategory.FileSystem);
      
              FileInfo fi = null;
              try
              {
                  fi = new FileInfo(GetBasePath(subFolderName) + fileName + ext);
                  fi.CopyTo(GetBasePath(subFolderName) + newName + ext);
      
                  pCallback?.Invoke();
              }
              catch (System.Exception e)
              {
                  AlertPopup.ShowAlert("error", "Error", e.Message);
                  HDLogger.LogError("Error copying " + subFolderName + "/" + fileName + " " + e.Message, HDLogger.LogCategory.FileSystem);
              }
              RefreshUnityDB();
          }
      
      
          public FileList ListFileItems(string subFolderName, Action<FileList> pCallback = null, string ext = "*.json")
          {
              FileList ll = new FileList();
              ll.list = new List<string>();
      
              if (mode == Mode.RESOURCES)
              {
                  UnityEngine.Object[] files = Resources.LoadAll(subFolderName + "/");
                  foreach (UnityEngine.Object o in files)
                  {
                      ll.list.Add(o.name);
                  }
              }
              else
              {
      
                  DirectoryInfo dir = new DirectoryInfo(GetBasePath(subFolderName));
                  Debug.Log("dir - "+ dir);
                  FileInfo[] info = dir.GetFiles(ext);
                  Debug.Log("info files count in - "+ subFolderName +" - "+ info.Length);
                  foreach (FileInfo f in info)
                  {
                      ll.list.Add(f.Name);
                  }
      
                  //ll.list.Add("House001");
              }
              HDLogger.Log("ListFileItems " + GetBasePath(subFolderName) + ":" + ll.list.Count, HDLogger.LogCategory.FileSystem);
              Debug.Log("ListFileItems " + GetBasePath(subFolderName) + ":" + ll.list.Count);
      
              pCallback?.Invoke(ll);
              return ll;
          }
      
      }

      }
      `

        You can't use it like so, please read this:

        Accessing streaming assets
        On Android and WebGL platforms, it’s not possible to access the streaming asset files directly via file system APIs and streamingAssets path because these platforms return a URL. Use the UnityWebRequest class to access the content instead.

        Notes:

        The streamingAssets path is read-only. Don’t modify or write new files to the streamingAssets directory at runtime.

        https://docs.unity3d.com/Manual/StreamingAssets.html

          Anthony Yes, This i aware. Please help on what are all the scripts need to modify except savesystem to make work for WebGL - stream using web request.

          Also any specific target deadlines for webGL support?

            benrajsd Only the save system needs to be adapted, I will work on a plugin for you for the save system + php server script.
            Which plugin do you own exactly? it will be part of the HOME DESIGNER BUNDLE for free but not in the individual packages.

              Anthony Thanks for the update. I am having home designer - full package. Is there any ETA for that package.

                benrajsd it's going to take me 2-3 weeks to implement properly but I will send you the basic code (unity + php) if you want to go ahead and implement it already.

                  15 days later

                  Anthony for future readers: the Online Module has been done and release with Home Designer Bundle, and soon as a separate plugin on the store

                    Write a Reply...