A way to wait for something?

Is there any way to do a Wait for something during the build process?
For instance, I would like to wait for a WebRequest upload during the postprocess step, but I can’t create a coroutine in the editor; And when I simply start uploading my files apparently the cloud build unity just closes and the uploads aren’t completed.

Is there any way to do this? Even if it must be a static predefined amout of time (maybe 60 seconds, or something like this), only to guarantee that the upload was sucessfully completed

Thanks

Hi @Uli_Okm ,

Something like this should work.

using System.Collections;
using UnityEngine.Networking;
using Debug = UnityEngine.Debug;

public static class CloudBuildHelper 
{
   public static void PostExport()
   {
      IEnumerator e = Upload();
      
      // While loop invoking MoveNext on enumerator
      while (e.MoveNext());
   }
   
   static IEnumerator Upload() {
      byte[] myData = System.Text.Encoding.UTF8.GetBytes("This is some test data");
      UnityWebRequest www = UnityWebRequest.Put("https://www.YourServerAddress.com", myData);
      yield return www.SendWebRequest();

      // Wait until the upload is done
      while (!www.isDone)
         yield return true;
      
      if(www.isNetworkError || www.isHttpError) {
         Debug.Log(www.error);
      }
      else {
         Debug.Log("Upload complete! " + www.responseCode);
      }
   }
}

Hope that helps!

3 Likes