0

类 Gettext 向 google.com 启动 Unitywebrewuest,但在控制台品脱“index1”后没有任何反应,也没有显示错误。我该如何解决/调试这个(在 Visual Studio 中我无法启动调试器)。

非常感谢您的时间!

public class Gettext : UnityEngine.MonoBehaviour
{
    private string m_fileContentWebGl = "aaa";
    public Gettext()
    {
        callGettext(m_fileContent => {
        });
    }


    public void callGettext(Action<string> onTextResult)
    {
        UnityEngine.Debug.Log("stage1");
        StartCoroutine(this.GetText(onTextResult));
        UnityEngine.Debug.Log("stage3");
    }

    public IEnumerator GetText(Action<string> onResult)
    {
        UnityEngine.Debug.Log("here");
        UnityWebRequest www = UnityWebRequest.Get("http://google.com");
        yield return www.SendWebRequest();
    }
}
4

1 回答 1

0

我认为您为单一行为派生类使用构造函数很奇怪。你不应该使用它们,这可能会影响协程,我不知道。

尝试改变

public Gettext()
    {
        callGettext(m_fileContent => {
        });
    }

void Start
    {
        callGettext(m_fileContent => {
        });
    }
于 2020-05-10T21:07:43.023 回答