Unity 爬坑日记(遇到小坑就记录一下)

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

原因:

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

解决方法:

UnityWebRequest 前加上using

 IEnumerator Post(callBack call)
    {
        WWWForm form = new WWWForm();
        form.AddField("name", "myData");
        form.AddField("id", "myData");
        form.AddField("message", "myData");

        using UnityWebRequest www = UnityWebRequest.Post(HttpConfig.goServer_url+postUrl, form);
        yield return www.SendWebRequest();

        if (www.result != UnityWebRequest.Result.Success)
        {
            Debug.Log(www.error);
        }
        else
        {
            Debug.Log("Form upload complete!");
            Debug.Log(www.downloadHandler.text);
        }
    }

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"

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值