当前位置:   UNITY > 正文

[Unity] IL2CPP WebGL 出现错误信息 FS.syncfs_webgl.loader.js:1 warning: 2 fs.syncfs operations

webgl.loader.js:1 warning: 2 fs.syncfs operations in flight at once, probabl

loader.js:1 warning: 2 FS.syncfs operations in flight at once, probably just doing extra work

Google浏览器中运行WebGL出现的错误

是因为写了加载和反序列化本地 JSON 文件(如下所示),则会输出上述警告

  1. public T LoadLocalData(string path) where T : class
  2. {
  3. try
  4. {
  5. using (var sw = new StreamReader(path))
  6. {
  7. var json = sw.ReadToEnd();
  8. return JsonUtility.FromJson<T>(json);
  9. }
  10. }
  11. catch (System.Exception e)
  12. {
  13. Debug.LogError($"Error: {path} | {e.Message}");
  14. }
  15. return null;
  16. }

WebGL中不允许使用文件操作

  1. public T LoadLocalData(string path) where T : class
  2. {
  3. #if UNITY_WEBGL
  4. // WebGL用其他代替处理
  5. return null;
  6. #else
  7. try
  8. {
  9. using (var sw = new StreamReader(path))
  10. {
  11. var json = sw.ReadToEnd();
  12. return JsonUtility.FromJson<T>(json);
  13. }
  14. }
  15. catch (System.Exception e)
  16. {
  17. Debug.LogError($"Error: {path} | {e.Message}");
  18. }
  19. return null;
  20. #endif
  21. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/blog/UNITY/detail/36097
推荐阅读
相关标签
  

闽ICP备14008679号