0

The Class Gettext starts a Unitywebrewuest to google.com but after the console pints "index1" nothing happens and no error are displayed. How could I solve / debug this ( in Visual Studio I can't start the debugger).

Thank you a lot for the time!

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();
    }
}
user12567588
  • 59
  • 1
  • 8

1 Answers1

0

I think its pretty odd that you are using a constructor for a monobehaviour derived class. You're not supposed to use them, that may be affecting the coroutine, I dunno.

Try changing

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

to

void Start
    {
        callGettext(m_fileContent => {
        });
    }
Guye Incognito
  • 2,726
  • 6
  • 38
  • 72