Uninomicon

Documenting the dark corners of the Unity Engine.

User Tools

Site Tools


unitywebrequest

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Last revision Both sides next revision
unitywebrequest [2021/05/30 16:26]
uninomiconadmin
unitywebrequest [2021/12/24 23:00]
archo on using UWR at exit time
Line 6: Line 6:
   * Android **must not** have ''file:⁄⁄'' prepended.   * Android **must not** have ''file:⁄⁄'' prepended.
   * Windows does not require ''file:⁄⁄'', but will tolerate it.   * Windows does not require ''file:⁄⁄'', but will tolerate it.
 +
 +==== Sending requests during destruction ====
 +
 +To ensure that UnityWebRequest operations are completed even if the MonoBehaviour is being destroyed (e.g. when the game is exiting), it appears to be safe on at least some platforms (such as Windows) to manually wait in a loop inside ''OnDestroy'' for ''isDone == true'' on the ''[UnityWebRequest]AsyncOperation'' object returned by ''Send[WebRequest]''.
 +
 +  * Note however that mobile platforms don't provide destruction callbacks at all and will usually simply kill the process.
 +  * It is recommended to limit the maximum running time of such a loop, and an appropriate time measurement method like ''System.Diagnostics.Stopwatch'' should be used for that since ''Time'' properties will not be updated and ''DateTime.UtcNow'' output can be changed by the user/system.
unitywebrequest.txt · Last modified: 2022/01/28 17:29 by 73.217.35.3