Answer the question
In order to leave comments, you need to log in
How to return yield www in Unity?
Hello! there is a code:
var request = WWW(apiAuthUrl, form);
yield request;
return request.text;
Answer the question
In order to leave comments, you need to log in
Option one - call the parser directly from the coroutine. If this is the only scenario for communicating with web forms, then it will do.
private void Start()
{
StartCoroutine(Request(apiAuthUrl, form));
}
private IEnumerator Request(string apiAuthUrl, byte[] form)
{
var request = new WWW(apiAuthUrl, form);
yield return request;
Parse(request.text);
}
private void Parse(string text)
{
Debug.Log(text);
}
private void Start()
{
StartCoroutine(Request(apiAuthUrl, form, Parse));
}
private IEnumerator Request(string apiAuthUrl, byte[] form, Action<string> callback)
{
var request = new WWW(apiAuthUrl, form);
yield return request;
callback(request.text);
}
private void Parse(string text)
{
Debug.Log(text);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question