Load saved File from folder in webGL?
-
- Posts: 11
- Joined: Thu Nov 30, 2023 3:20 pm
Load saved File from folder in webGL?
hello,
I have a problem with ES3, I cant navigate to find the file that I managed to save. For instance, in Unity editor I can save and load a file easily but when I switch to my build in WebGL, I cant find a way to open the save file. I'm still able to save but only directly in a folder such as "download", but I dont know how to let the player be able to choose a save location , same problem with loading a file from the user PC, can't choose the location. How do I do that with ES3?
Also, this is the path that I get and the bottom one should be the same as the top one.
If I'm not mistaken, we use UnityWebRequest to know if the file exist and we receive that URL but with ES3 that doesn't work. It works fine when we read a picture (bytes).
This is when using desktop
file:///C:/Users/devpm/AppData/LocalLow/DefaultCompany/Planer/SaveFile.es3
This is when using WebGL(by the way the pma.kalanda.info is the domain name where we host the game)
blob:https://pma.kalanda.info/dedd4a01-9f21- ... 76659b602f
So my question is, how do we save/load files using ES3 on WebGL and let the player find/choose the correct folder ?
I have a problem with ES3, I cant navigate to find the file that I managed to save. For instance, in Unity editor I can save and load a file easily but when I switch to my build in WebGL, I cant find a way to open the save file. I'm still able to save but only directly in a folder such as "download", but I dont know how to let the player be able to choose a save location , same problem with loading a file from the user PC, can't choose the location. How do I do that with ES3?
Also, this is the path that I get and the bottom one should be the same as the top one.
If I'm not mistaken, we use UnityWebRequest to know if the file exist and we receive that URL but with ES3 that doesn't work. It works fine when we read a picture (bytes).
This is when using desktop
file:///C:/Users/devpm/AppData/LocalLow/DefaultCompany/Planer/SaveFile.es3
This is when using WebGL(by the way the pma.kalanda.info is the domain name where we host the game)
blob:https://pma.kalanda.info/dedd4a01-9f21- ... 76659b602f
So my question is, how do we save/load files using ES3 on WebGL and let the player find/choose the correct folder ?
Re: Load saved File from folder in webGL?
Hi there,
WebGL stores files in isolated storage rather than a physical file on the hard disk (this behaviour is defined at their end rather than ours). WebGL doesn't allow storing files in the file system for security reasons (otherwise it would be easy for WebGL to be used for malicious purposes).
Regarding allowing a user to select a location, you would need to use a file browser asset to allow them to select a location. You can then provide this path to the filePath parameters of the Easy Save methods. However, we usually only recommend allowing users to save to Unity's persistent data path as this is the only place guaranteed to have the required security privileges.
All the best,
Joel
WebGL stores files in isolated storage rather than a physical file on the hard disk (this behaviour is defined at their end rather than ours). WebGL doesn't allow storing files in the file system for security reasons (otherwise it would be easy for WebGL to be used for malicious purposes).
Regarding allowing a user to select a location, you would need to use a file browser asset to allow them to select a location. You can then provide this path to the filePath parameters of the Easy Save methods. However, we usually only recommend allowing users to save to Unity's persistent data path as this is the only place guaranteed to have the required security privileges.
All the best,
Joel
-
- Posts: 11
- Joined: Thu Nov 30, 2023 3:20 pm
Re: Load saved File from folder in webGL?
Hello,
Thanks for your time and response, Joel.
I understand the limitations imposed by WebGL on file storage for security reasons. However, I'm aiming to implement a feature similar to other applications like "draw.io," where users can choose a specific folder on their PC or Dropbox to save their projects. This would make it more convenient for users to share their saved files.
Is there any workaround or specific approach you would recommend to achieve this functionality in a WebGL environment using ES3?
Appreciate your assistance.
Thanks for your time and response, Joel.
I understand the limitations imposed by WebGL on file storage for security reasons. However, I'm aiming to implement a feature similar to other applications like "draw.io," where users can choose a specific folder on their PC or Dropbox to save their projects. This would make it more convenient for users to share their saved files.
Is there any workaround or specific approach you would recommend to achieve this functionality in a WebGL environment using ES3?
Appreciate your assistance.
Re: Load saved File from folder in webGL?
Hi there,
There's no way to access the file system with WebGL, so this unfortunately wouldn't be possible. Just to clarify, draw.io uses HTML5 rather than WebGL/Unity so doesn't have the same limitations.
The only way to achieve something similar on WebGL would be to upload and download their data to and from the cloud, rather than using the file system.
All the best,
Joel
There's no way to access the file system with WebGL, so this unfortunately wouldn't be possible. Just to clarify, draw.io uses HTML5 rather than WebGL/Unity so doesn't have the same limitations.
The only way to achieve something similar on WebGL would be to upload and download their data to and from the cloud, rather than using the file system.
All the best,
Joel
-
- Posts: 11
- Joined: Thu Nov 30, 2023 3:20 pm
Re: Load saved File from folder in webGL?
Hi Joel,
Thanks for your response.
I recently came across a Unity plugin called "WebGL Native File Browser" on the Unity Asset Store (https://assetstore.unity.com/packages/t ... wser-41902), which seems to provide file system access in a WebGL environment. It caught my attention as it seems to offer file system access in a WebGL environment, contrary to the limitations we discussed.
Could you please take a look at this plugin and provide some insights? It appears to present a potential solution for file system interaction in a WebGL context. I'm want to understand how this plugin aligns with the constraints you outlined and if it could be a viable option for our requirements.
Thank you for your time and assistance.
Best regards, William
Thanks for your response.
I recently came across a Unity plugin called "WebGL Native File Browser" on the Unity Asset Store (https://assetstore.unity.com/packages/t ... wser-41902), which seems to provide file system access in a WebGL environment. It caught my attention as it seems to offer file system access in a WebGL environment, contrary to the limitations we discussed.
Could you please take a look at this plugin and provide some insights? It appears to present a potential solution for file system interaction in a WebGL context. I'm want to understand how this plugin aligns with the constraints you outlined and if it could be a viable option for our requirements.
Thank you for your time and assistance.
Best regards, William
Re: Load saved File from folder in webGL?
Hi William,
To my knowledge that asset will not work anymore as it likely uses a workaround which relied on custom JS client code and Application.ExternalEval, which is only available in certain versions of Unity and which was made obsolete for security reasons. In theory this would only also work if you have control of the Javascript on the page your WebGL is hosted on anyway, and the browser provides the required security.
We avoid things which deviate from WebGL's specification because it's likely in the future that such workarounds will be patched.
All the best,
Joel
To my knowledge that asset will not work anymore as it likely uses a workaround which relied on custom JS client code and Application.ExternalEval, which is only available in certain versions of Unity and which was made obsolete for security reasons. In theory this would only also work if you have control of the Javascript on the page your WebGL is hosted on anyway, and the browser provides the required security.
We avoid things which deviate from WebGL's specification because it's likely in the future that such workarounds will be patched.
All the best,
Joel
-
- Posts: 11
- Joined: Thu Nov 30, 2023 3:20 pm
Re: Load saved File from folder in webGL?
Hi again,
Thanks for the explanation. I appreciate your insights.
you mentioned utilizing cloud upload and download for file operations. Could you share any examples or documentation that could assist me in implementing this approach?
Your guidance would be highly valuable.
Appreciate your help.
Thanks for the explanation. I appreciate your insights.
you mentioned utilizing cloud upload and download for file operations. Could you share any examples or documentation that could assist me in implementing this approach?
Your guidance would be highly valuable.
Appreciate your help.
Re: Load saved File from folder in webGL?
Hi there,
We have our own cloud functionality here:
https://docs.moodkie.com/easy-save-3/es ... -es3cloud/
Or you can integrate into a cloud service of your choice using the instructions here:
https://docs.moodkie.com/easy-save-3/es ... rage-apis/
All the best,
Joel
We have our own cloud functionality here:
https://docs.moodkie.com/easy-save-3/es ... -es3cloud/
Or you can integrate into a cloud service of your choice using the instructions here:
https://docs.moodkie.com/easy-save-3/es ... rage-apis/
All the best,
Joel
-
- Posts: 11
- Joined: Thu Nov 30, 2023 3:20 pm
Re: Load saved File from folder in webGL?
Hi Joel,
Thanks for providing the resources. I've successfully set up my cloud functionality using your documentation. Now, I'm looking to load data using "ES3.Load<T>(key, filename);" but I'm a bit unsure about the implementation details. Could you guide me on how to use this function effectively?
Appreciate your assistance.
Thanks for providing the resources. I've successfully set up my cloud functionality using your documentation. Now, I'm looking to load data using "ES3.Load<T>(key, filename);" but I'm a bit unsure about the implementation details. Could you guide me on how to use this function effectively?
Appreciate your assistance.
Re: Load saved File from folder in webGL?
Hi there,
I recommend taking a look at the Getting Started guide as this explains how to use ES3.Load:
https://docs.moodkie.com/easy-save-3/getting-started/
All the best,
Joel
I recommend taking a look at the Getting Started guide as this explains how to use ES3.Load:
https://docs.moodkie.com/easy-save-3/getting-started/
All the best,
Joel