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
Next revision
Previous revision
unitywebrequest [2021/05/30 16:26]
uninomiconadmin
unitywebrequest [2022/01/28 17:29] (current)
73.217.35.3
Line 1: Line 1:
 ====== UnityWebRequest ====== ====== UnityWebRequest ======
  
 +==== Local Filesystem Requests ====
 When using UnityWebRequest to load from the local filesystem: When using UnityWebRequest to load from the local filesystem:
  
Line 6: Line 7:
   * 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.1622391982.txt.gz · Last modified: 2021/05/30 16:26 by uninomiconadmin