Title: How to launch coroutine in Editor with the "Editor coroutine" package?
Tags: c#;unity3d;coroutine
Question: I'm trying to build a tool in the Unity Editor with an EditorWindow on his own. This tool will need to access a MySQL DB through PHP files so I need to use coroutines. I looked for a solution and fall upon a preview package "Editor Coroutine" and installed it. I don't see how it works and the documentation doesn't say anything (or anything i've understanded) about how to use it. Do you know any way to make this thing work properly ?
I've tried to simply do a "StartCoroutine()", to call it from an Editor class or to create an object (GameObject) to call it, but none of this work :/.

Here is the accepted answer: I faced the same problem. I ended up with the following code, which executes the webrequest in a non-coroutine method.
private void UpdateVersion(string message)
string post_url = NetworkManager.baseUrl + "VersionUpdate.php";
WWWForm form = new WWWForm();
form.AddField("Message", message);
form.AddField("Version", Application.version);
UnityWebRequest www = UnityWebRequest.Post(post_url, form);
www.chunkedTransfer = false;
www.SendWebRequest();
while (!www.isDone)
// do nothing
}
if(www.error == null){
Debug.Log(www.downloadHandler.text);
} else {
Debug.Log("error!: " + www.error);

Here is another answer: Be aware that the accepted answer's while loop completely blocks the Editor until the download is done. For a simple text that might be fine but for larger files this might become an issue.
There is however EditorApplication.update you can subscripe to in order to call a method every frame in the Editor. So for an EditorWindow you could do something like
private IEnumerator currentDownload;
private void ProcessDownload()
if(currentDownload!=null) currentDownload.MoveNext();
private IEnumerator UpdateVersion(string message)
string post_url = NetworkManager.baseUrl + "VersionUpdate.php";
WWWForm form = new WWWForm();
form.AddField("Message", message);
form.AddField("Version", Application.version);
UnityWebRequest www = UnityWebRequest.Post(post_url, form);
www.chunkedTransfer = false;
yield return www.SendWebRequest();
if(www.error == null){
Debug.Log(www.downloadHandler.text);
} else {
Debug.Log("error!: " + www.error);
and use it like
// makes sure the callback is added only once
EditorApplication.update -= ProcessDownload;
EditorApplication.update += ProcessDownload;
currentDownload = UpdateVersion("whatever string");
Comment for this answer: Thanks for your answer, I will look into this a bit later though, I'm in a project with a limited time and even if the accepted answer isn't perfect, it works and I need to move on :/

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2019:00:04/01/19', 'FavoriteCount': 1.0, 'PostTypeId': 1, 'Tags': '<c#><unity3d><coroutine>', 'Title': 'How to launch coroutine in Editor with the "Editor coroutine" package?', 'ViewCount': 3241, 'id': 55449874, 'user_AboutMe': "<p>I'm a 22 years old developer, currently working in digital services but overall graduated from a video game school. I'm also French so my English will not be perfect, but I try to improve myself as much as y can. I hope I will be able to help people here and also to found answers to my questions !</p>\n", 'user_AccountId': 14924995.0, 'user_DisplayName': 'Laura', 'user_Reputation': 35.0, 'user_Views': 42.0, 'user_id': 10776146.0}}