在第二轮中没有返回“yield return WWW”方法

时间:2013-11-26 01:12:12

标签: debugging web return unity3d yield

我在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”。

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

我应该为Unity3D环境应用哪些特定设置,以便我不需要仅使用真实设备调试我的代码?

1 个答案:

答案 0 :(得分:0)

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

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

如果要保持Collapse已启用,请将Debug.Logs更改为包含Time.time,如下所示:

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

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