【问题标题】:No return of "yield return WWW" method in the second run第二次运行“yield return WWW”方法没有返回
【发布时间】:2013-12-10 23:40:48
【问题描述】:

我在 Unity3D 环境中跟踪以下方法: (通过 StartCoroutine 调用)

private IEnumerator post(string s) {
    Debug.Log("Posting to Server: " + s);

    WWWForm form = new WWWForm();
    form.AddField("data", s);   

    WWW yaPoster = new WWW(YMCA_URL,form);  

        Debug.log("11111");     
        yield return yaPoster;  
        Debug.log("22222");

        if(yaPoster.error != null) {  
            Debug.Log(yaPoster.error);
        }  
        else {  
            Debug.Log(yaPoster.text);
        }

    yaPoster = null;    
}   

每次第一次都能正常工作(从日志控制台看到 yaPoster.text),但在随后的调用中永远看不到“11111”或“22222”。

(不)令人惊讶的是,在我的 iPod 设备上使用内置的 iOS Xcode 项目运行良好。

我应该为我的 Unity3D 环境应用任何特定设置,这样我就不需要只使用真实设备调试我的代码?

【问题讨论】:

    标签: debugging web return unity3d yield


    【解决方案1】:

    看起来应该可以正常工作!

    一个大胆的猜测:在控制台中关闭折叠?可能是您第二次看不到它,因为如果启用 Collapse 则不会显示相同的消息

    如果您想保持 Collapse 处于启用状态,请将您的 Debug.Logs 更改为包含 Time.time,如下所示:

    Debug.Log(Time.time + ": " + "11111"); //adding some uniqueness to keep it from collapsing
    

    (抱歉,没有足够的代表发表评论)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-26
      • 2021-10-29
      • 1970-01-01
      • 2021-02-15
      • 1970-01-01
      • 1970-01-01
      • 2015-03-17
      • 1970-01-01
      相关资源
      最近更新 更多