You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Unity macOS应用仅在Applications文件夹运行时挂起的解决方法

Unity macOS应用复制到Applications目录后异步操作挂起30秒问题

我开发了一款Unity macOS应用,在调试器中运行正常,从构建目录运行也正常,但将*.app文件复制到Applications文件夹后,执行异步操作时会挂起30秒。整个应用完全冻结,鼠标光标变为macOS的无响应动画。请问有人知道原因及解决方法吗?

核心代码

private void Start()
{
  StartCoroutine(StartLate());
}

IEnumerator StartLate()
{
  yield return null;

  using (UnityWebRequest www = UnityWebRequest.Get("<my url>"))
  {
    UnityWebRequestAsyncOperation async = www.SendWebRequest();

    int i=0;
    while (!async.isDone)
    {
      Debug.Log(i++);
      yield return null;
    }
    Debug.Log("Complete");

    // 实际处理结果...

  }
}

运行输出对比

  • 在Unity调试器或构建目录中的独立版本运行时,输出:
    1 2 3 4 5 6 7 8 9..... 100 101 Complete
  • 复制到Applications目录运行时,输出:
    1 2 3 4 5 6 7 8 9..... 100 101 <30秒挂起> Complete

编辑补充

经确认,异步模式并非问题所在。当核心代码为以下两种形式时,也会出现仅在Applications目录运行时暂停的情况:

形式一:

www.SendWebRequest();
while (!www.isDone)
  yield return null;

形式二:

yield return www.SendWebRequest();

内容的提问来源于stack exchange,提问作者Dogtanian

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 17:17:11