当前位置:   article > 正文

Unity 爬坑日记(遇到小坑就记录一下)_an error occurred while resolving packages: one or

an error occurred while resolving packages: one or more packages could not b

A Native Collection has not been disposed, resulting in a memory leak.  Enable Full StackTraces to get more details.

原因:

数据请求提交过程中,UnityWebRequest 不时出现数据没有释放的情况,偶尔会一部分数据
内存溢出情况:

解决方法:

UnityWebRequest 前加上using

  1. IEnumerator Post(callBack call)
  2. {
  3. WWWForm form = new WWWForm();
  4. form.AddField("name", "myData");
  5. form.AddField("id", "myData");
  6. form.AddField("message", "myData");
  7. using UnityWebRequest www = UnityWebRequest.Post(HttpConfig.goServer_url+postUrl, form);
  8. yield return www.SendWebRequest();
  9. if (www.result != UnityWebRequest.Result.Success)
  10. {
  11. Debug.Log(www.error);
  12. }
  13. else
  14. {
  15. Debug.Log("Form upload complete!");
  16. Debug.Log(www.downloadHandler.text);
  17. }
  18. }

Curl error 28: Failed to connect to 10.110.83.193 port 1880 after 21043 ms: Timed out

原因:

许可证问题。

解决方法:

unity hub登出。

xxx  is not a valid directory name. Please make sure there are no unallowed characters in the name.

原因:项目设置中项目名称包含空格。

 解决方法:将空格删掉。

An error occurred while resolving packages:
  One or more packages could not be added to the local file system:
    com.autodesk.fbx: Cannot connect to 'download.packages.unity.com' (error code: ECONNREFUSED). Verify your environment firewall policies allow connection to this host name. If your system is behind a proxy, verify your proxy environment variables (HTTP_PROXY and HTTPS_PROXY) are properly set.
    com.unity.formats.fbx: Cannot connect to 'download.packages.unity.com' (error code: ECONNREFUSED). Verify your environment firewall policies allow connection to this host name. If your system is behind a proxy, verify your proxy environment variables (HTTP_PROXY and HTTPS_PROXY) are properly set.

A re-import of the project may be required to fix the issue or a manual modification of D:/Work/20230110_zhangpeng/gitee/ZhangGu_3D-main-1/ZhangGu_3D-main/Packages/manifest.json file.

解决方法:

将Packages/manifest.json,删除重新加载。

WebGL跨域问题

开发webgl的项目,在编译器里用get和post请求没问题,但是打包出来以后就出现问题了。

from origin 'file://' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

这种错误就是出现了跨域问题。一般这种问题我们都是交给写后端接口的同事来处理

当然我们也有另外的处理方法,就是设置谷歌浏览器(chrome)允许跨域。

直接创建chrome浏览器的快捷方式,在属性中找到打开路径,在…chrome.exe后面加上

--args --disable-web-security --user-data-dir="C:/ChromeDevSession"

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/blog/article/detail/92728
推荐阅读
相关标签
  

闽ICP备14008679号