- Home /
Problem is not reproducible or outdated
Sending 2 strings to coroutine does not seem to work
Hi All, I have a method that has two strings in it,
public void GetValues(string emailText, string passwordText)
{
Debug.Log(emailText + passwordText);
StartCoroutine(Send(emailText, passwordText));
}
Debug.Log works fine, but when I pass it to my Coroutine,
private IEnumerator Send(string emailText, string passwordText)
{
Debug.Log(emailText + passwordText);
}
I get nothing in my Debug.Log. Could not figure out what is wrong for hours Please help!
Is the gameObject holding the script enabled? A disabled object can't run coroutines.
Is the content of the Send
method only what you've provided?
Yes, the gameObject is enabled. Otherwise, the GetValues Method would not work.
The rest of the method goes below Debug.Log(). Here it is:
private IEnumerator Send(string emailText, string passwordText) { Debug.Log(emailText); WWWForm form = new WWWForm(); form.AddField("WelcomeMSG", "DD"); WWW www = new WWW("https://dasomsaassist.com/", form); yield return www; if(www.error !=null) { Debug.Log("error: " + www.error); yield break; } Debug.Log("Answer: " + www.text); }
Answer by heislerc0 · Dec 28, 2021 at 10:57 PM
Unity tends to group logs that are the same. In your console do you see something like this?
emailpassword (2)
Your coroutine may be logging and being grouped with the first one. Sorry if that doesn't help, nothing jumps out as wrong to me with the code.
Answer by Deksover · Dec 29, 2021 at 08:42 AM
Hi. Thank you for your answers. The issue was in the main class where I called the Coroutine.
It did not start from the main thread so it did not work. The issue is fixed now.
Without the full code provided, it was impossible to understand what was wrong, my bad.
Follow this Question
Related Questions
Backspace typewriter effect 1 Answer
If statement inside Coroutine firing without meeting the conditions 2 Answers
iOS Unity randomly hangs on yield return www 0 Answers
Download multiple textures 0 Answers
Make label disappear after 1 second? 3 Answers