Skip to content

Instantly share code, notes, and snippets.

@srcnalt
Last active April 22, 2023 22:07
Show Gist options
  • Save srcnalt/59925cb38d74de80528df4cb5e9c8c09 to your computer and use it in GitHub Desktop.
Save srcnalt/59925cb38d74de80528df4cb5e9c8c09 to your computer and use it in GitHub Desktop.
Useful Extension Methods
/// <summary>
/// Extension method to allow UnityWebRequest to be used with async/await.
/// </summary>
/// <param name="request">The UnityWebRequest to await.</param>
public async static Task SendRequestAsync(this UnityWebRequest request)
{
UnityWebRequestAsyncOperation op = request.SendWebRequest();
while(!op.isDone) await Task.Yield();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment