diff --git a/Runtime/GeoTiffHeight.cs b/Runtime/GeoTiffHeight.cs index 5e85e58c1ddd63a06e0d1c801a1a15123dfb869e..1f51100fcc7ea82d164fbf709574ad801c18d370 100644 --- a/Runtime/GeoTiffHeight.cs +++ b/Runtime/GeoTiffHeight.cs @@ -60,14 +60,15 @@ namespace Wander internal bool valid; internal int numRings; internal bool filter; - internal bool finished; internal float invalidSample; internal UnityWebRequest www; internal bool started; + internal bool retried; internal Task<HeightData> decodeTiffBytesTask; public HeightData HeightData => heightData; public bool Valid => valid; + public bool Retried => retried; public bool Started => started; @@ -81,14 +82,28 @@ namespace Wander } } + public void Retry() + { + Debug.Assert( started ); + Debug.Assert( !retried, "Already retried" ); + www = UnityWebRequest.Get( www.uri ); + www.SendWebRequest(); + retried = true; + } + public bool IsFinished() { - if (finished || www == null) + if (www == null) return true; // Still in progress - if (!www.isDone) - return false; + if (www.result == UnityWebRequest.Result.InProgress) // If there is an error, then Done is not set true.. + { + if (!www.isDone) + return false; + } + + // Either isDone is true, or result is error but not InProgress. // Request is done, but not valid. if (www.result != UnityWebRequest.Result.Success) @@ -140,10 +155,10 @@ namespace Wander } decodeTiffBytesTask = null; www = null; - finished = true; + return true; } - return finished; + return false; } }