Documenting the dark corners of the Unity Engine.

User Tools

Site Tools



Local Filesystem Requests

When using UnityWebRequest to load from the local filesystem:

  • macOS and iOS require that file:⁄⁄ be prepended to the location.
  • Android must not have file:⁄⁄ prepended.
  • 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