Implemented 1st version of UI for updater

This commit is contained in:
2018-08-18 23:19:31 +02:00
parent 8795320416
commit 1642cd37ac
3 changed files with 1161 additions and 10 deletions

View File

@@ -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);
}
}
}

View File

@@ -11,6 +11,7 @@ Material:
m_ShaderKeywords:
m_LightmapFlags: 5
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 3000
stringTagMap: {}
disabledShaderPasses: []
@@ -62,7 +63,7 @@ Material:
- _OutlineSoftness: 0
- _OutlineUVSpeedX: 0
- _OutlineUVSpeedY: 0
- _OutlineWidth: 0.091
- _OutlineWidth: 0.1
- _PerspectiveFilter: 0.875
- _Reflectivity: 10
- _ScaleRatioA: 0.9
@@ -93,7 +94,7 @@ Material:
- _FaceColor: {r: 1, g: 1, b: 1, a: 1}
- _GlowColor: {r: 0, g: 1, b: 0, a: 0.5}
- _MaskCoord: {r: 0, g: 0, b: 32767, a: 32767}
- _OutlineColor: {r: 0, g: 0, b: 0, a: 1}
- _OutlineColor: {r: 1, g: 1, b: 1, a: 1}
- _ReflectFaceColor: {r: 0, g: 0, b: 0, a: 1}
- _ReflectOutlineColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecularColor: {r: 1, g: 1, b: 1, a: 1}
@@ -107,6 +108,8 @@ Texture2D:
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
serializedVersion: 2
m_Width: 1024
m_Height: 1024
@@ -118,10 +121,13 @@ Texture2D:
m_ImageCount: 1
m_TextureDimension: 2
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 1
m_MipBias: 0
m_WrapMode: 0
m_WrapU: 0
m_WrapV: 0
m_WrapW: 0
m_LightmapFormat: 0
m_ColorSpace: 0
image data: 1048576

File diff suppressed because it is too large Load Diff