Implemented 1st version of UI for updater
This commit is contained in:
@@ -11,8 +11,9 @@ namespace RothenburgAR.Updater
|
||||
{
|
||||
public class UpdaterBehaviour : MonoBehaviour
|
||||
{
|
||||
public VersioncheckAnswer VersionAnswer { get; set; }
|
||||
public UnityEngine.UI.Slider ProgressBar;
|
||||
|
||||
public VersioncheckAnswer VersionAnswer { get; set; }
|
||||
private List<HttpHandler> httpHandlers = new List<HttpHandler>();
|
||||
|
||||
void Start()
|
||||
@@ -159,6 +160,8 @@ namespace RothenburgAR.Updater
|
||||
//exhibit.MediaId;
|
||||
//exhibit.Pois[0].ImageId;
|
||||
|
||||
//TODO check existing file for creation/alteration date to see if download is necessary
|
||||
|
||||
var mediaIDs = new List<string> { exhibit.MediaId };
|
||||
//var mediaIDs = exhibit.Pois.Select(p => p.ImageId).ToList();
|
||||
|
||||
@@ -175,7 +178,7 @@ namespace RothenburgAR.Updater
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
@@ -193,7 +196,7 @@ namespace RothenburgAR.Updater
|
||||
if (http.request.isNetworkError || http.request.isHttpError)
|
||||
{
|
||||
//TODO notify user about error (decide on level of detail)
|
||||
Debug.LogError(String.Format("Error while downloading\nurl: {0}\nNetwork Error: {1}\nHttp Error: {2}\nHttp Response Code: {3}",
|
||||
Debug.LogError(String.Format("Error while downloading\nurl: {0}\nNetwork Error: {1}\nHttp Error: {2}\nHttp Response Code: {3}",
|
||||
http.request.url,
|
||||
http.request.isNetworkError,
|
||||
http.request.isHttpError,
|
||||
@@ -214,12 +217,40 @@ namespace RothenburgAR.Updater
|
||||
UnityEngine.SceneManagement.SceneManager.LoadScene("mainScene");
|
||||
}
|
||||
|
||||
private DateTime downloadEndedTime = DateTime.Now.AddSeconds(1);
|
||||
private float afterDownloadWaitTime = 3f;
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (httpHandlers.Count > 0)
|
||||
{
|
||||
float downloadProgress = 0f;
|
||||
httpHandlers.ForEach(h =>
|
||||
{
|
||||
downloadProgress += h.operation.progress;
|
||||
});
|
||||
|
||||
downloadProgress /= httpHandlers.Count;
|
||||
|
||||
ProgressBar.value = downloadProgress;
|
||||
}
|
||||
|
||||
// Continue to Main Scene after all downloads are done and 3 seconds have passed without any new downloads triggering.
|
||||
if (httpHandlers.All(h => h.IsDone))
|
||||
{
|
||||
Debug.Log("Done Updating");
|
||||
LoadMainScene();
|
||||
if (downloadEndedTime > DateTime.Now)
|
||||
{
|
||||
downloadEndedTime = DateTime.Now;
|
||||
}
|
||||
if (downloadEndedTime.AddSeconds(afterDownloadWaitTime) < DateTime.Now)
|
||||
{
|
||||
Debug.Log("Done Updating");
|
||||
LoadMainScene();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
downloadEndedTime = DateTime.Now.AddSeconds(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user