first commit to make Updates a background task for normal app launch
This commit is contained in:
@@ -913,8 +913,8 @@ MonoBehaviour:
|
||||
m_TargetGraphic: {fileID: 114224566756848850}
|
||||
m_HandleRect: {fileID: 224135889778237342}
|
||||
m_Direction: 2
|
||||
m_Value: 0.9999998
|
||||
m_Size: 0.5452254
|
||||
m_Value: 0.50000024
|
||||
m_Size: 0.5452256
|
||||
m_NumberOfSteps: 0
|
||||
m_OnValueChanged:
|
||||
m_PersistentCalls:
|
||||
@@ -1343,7 +1343,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 2100000, guid: 184173fb9a2399341882a894edcac032, type: 2}
|
||||
m_Material: {fileID: 2100000, guid: a5b7496cf6d1ca34bab1a076f7b545e0, type: 2}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 0
|
||||
m_OnCullStateChanged:
|
||||
@@ -1579,7 +1579,7 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: -195.90994}
|
||||
m_AnchoredPosition: {x: 0, y: -0.000076293945}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!224 &224254431283456606
|
||||
|
||||
3041
Assets/Resources/UI/UpdaterView.prefab
Normal file
3041
Assets/Resources/UI/UpdaterView.prefab
Normal file
File diff suppressed because it is too large
Load Diff
10
Assets/Resources/UI/UpdaterView.prefab.meta
Normal file
10
Assets/Resources/UI/UpdaterView.prefab.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab149fbc9d7dc3d40ac85af2e411788a
|
||||
timeCreated: 1546010792
|
||||
licenseType: Free
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 100100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -2,6 +2,7 @@
|
||||
using RothenburgAR.Exhibition;
|
||||
using RothenburgAR.PointOfInterest;
|
||||
using RothenburgAR.UI;
|
||||
using RothenburgAR.Updater;
|
||||
using UnityEngine;
|
||||
using Vuforia;
|
||||
|
||||
@@ -15,6 +16,15 @@ namespace RothenburgAR
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
#if !UNITY_EDITOR
|
||||
logFileHandler = new LogFileHandler();
|
||||
#else
|
||||
Debug.Log("Found Unity Editor; Disabled logging into file.");
|
||||
#endif
|
||||
//OBJLoader.defaultShader = Shader.Find("Standard (Specular setup)")
|
||||
OBJLoader.defaultShader = Shader.Find("Standard");
|
||||
OBJLoader.defaultMaterial = new Material(OBJLoader.defaultShader);
|
||||
|
||||
LanguageManager.Instance.LoadLanguagesFromXml();
|
||||
UIColorSchemeManager.Instance.Initialize();
|
||||
|
||||
@@ -26,11 +36,8 @@ namespace RothenburgAR
|
||||
UIManager.Instance.InitStartView();
|
||||
|
||||
InputManager.Instance.Initialize();
|
||||
var init = DisplayManager.Instance;
|
||||
|
||||
//OBJLoader.defaultShader = Shader.Find("Standard (Specular setup)")
|
||||
OBJLoader.defaultShader = Shader.Find("Standard");
|
||||
OBJLoader.defaultMaterial = new Material(OBJLoader.defaultShader);
|
||||
var initDisplayManagerSingleton = DisplayManager.Instance;
|
||||
var initUpdaterSingleton = UpdaterBehaviour.Instance;
|
||||
}
|
||||
|
||||
void InitializeData()
|
||||
|
||||
69
Assets/RothenburgAR/Scripts/UI/UpdaterViewBehaviour.cs
Normal file
69
Assets/RothenburgAR/Scripts/UI/UpdaterViewBehaviour.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using RothenburgAR.Updater;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RothenburgAR.UI
|
||||
{
|
||||
public class UpdaterViewBehaviour : MonoBehaviour
|
||||
{
|
||||
public UnityEngine.UI.Slider ProgressBar;
|
||||
public GameObject UpdateDialog;
|
||||
public GameObject UpdateConfirmationDialog;
|
||||
public GameObject UpdateCompletedDialog;
|
||||
public GameObject UpdateFailedDialog;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
UpdateDialog.SetActive(false);
|
||||
UpdateConfirmationDialog.SetActive(false);
|
||||
UpdateCompletedDialog.SetActive(false);
|
||||
UpdateFailedDialog.SetActive(false);
|
||||
ProgressBar.value = 0;
|
||||
ProgressBar.maxValue = 1;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
var state = UpdaterBehaviour.Instance.UpdateState;
|
||||
|
||||
UpdateDialog.SetActive(false);
|
||||
UpdateConfirmationDialog.SetActive(false);
|
||||
UpdateCompletedDialog.SetActive(false);
|
||||
UpdateFailedDialog.SetActive(false);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case UpdateState.ConfirmationPending:
|
||||
UpdateConfirmationDialog.SetActive(true);
|
||||
break;
|
||||
|
||||
case UpdateState.UpdatesFound:
|
||||
case UpdateState.Downloading:
|
||||
UpdateDialog.SetActive(true);
|
||||
|
||||
ProgressBar.value = UpdaterBehaviour.Instance.CurrentProgress;
|
||||
ProgressBar.maxValue = UpdaterBehaviour.Instance.MaxProgress;
|
||||
break;
|
||||
|
||||
case UpdateState.Completed:
|
||||
UpdateCompletedDialog.SetActive(true);
|
||||
//TODO add "apply upgrades" button or sth that Destroys all DontDestroyOnLoads and reloads the scene, use AppInitializerBehaviour for that
|
||||
break;
|
||||
|
||||
case UpdateState.Failed:
|
||||
UpdateFailedDialog.SetActive(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void TriggerUpdate()
|
||||
{
|
||||
UpdaterBehaviour.Instance.TriggerUpdate();
|
||||
}
|
||||
|
||||
public void ExitView()
|
||||
{
|
||||
UIManager.Instance.SwitchToView(ViewName.ARView);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
13
Assets/RothenburgAR/Scripts/UI/UpdaterViewBehaviour.cs.meta
Normal file
13
Assets/RothenburgAR/Scripts/UI/UpdaterViewBehaviour.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 49d9434809cb84c44ae021b275939980
|
||||
timeCreated: 1546011854
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -11,51 +11,43 @@ using System.Text.RegularExpressions;
|
||||
|
||||
namespace RothenburgAR.Updater
|
||||
{
|
||||
public class UpdaterBehaviour : MonoBehaviour
|
||||
public enum UpdateState
|
||||
{
|
||||
public UnityEngine.UI.Slider ProgressBar;
|
||||
public GameObject UpdateDialog;
|
||||
public GameObject UpdateConfirmationDialog;
|
||||
public GameObject UpdateCompletedDialog;
|
||||
public GameObject UpdateFailedDialog;
|
||||
UpdatesFound,
|
||||
ConfirmationPending,
|
||||
Downloading,
|
||||
Completed,
|
||||
Failed
|
||||
}
|
||||
|
||||
public class UpdaterBehaviour : Singleton<UpdaterBehaviour>
|
||||
{
|
||||
public UpdateState UpdateState { get; private set; }
|
||||
|
||||
public int CurrentProgress { get; private set; }
|
||||
public int MaxProgress { get; private set; }
|
||||
|
||||
private float afterDownloadWaitTime = 10f;
|
||||
private readonly int retriesUntilFailure = 4;
|
||||
private readonly string trackerMainFile = "tracker.dat";
|
||||
|
||||
public ApiVersioncheckAnswer VersionAnswer { get; set; }
|
||||
|
||||
Dictionary<string, List<ApiExhibit>> ExhibitMetas = new Dictionary<string, List<ApiExhibit>>();
|
||||
private LogFileHandler logFileHandler;
|
||||
|
||||
void Start()
|
||||
{
|
||||
#if !UNITY_EDITOR
|
||||
logFileHandler = new LogFileHandler();
|
||||
#else
|
||||
Debug.Log("Found Unity Editor; Disabled logging into file.");
|
||||
#endif
|
||||
InitUI();
|
||||
|
||||
if (Application.internetReachability == NetworkReachability.NotReachable)
|
||||
{
|
||||
// just continue to app
|
||||
LoadMainScene();
|
||||
UpdatesCompleted();
|
||||
return;
|
||||
}
|
||||
|
||||
CheckForUpdates();
|
||||
}
|
||||
|
||||
private void InitUI()
|
||||
{
|
||||
FindObjectsOfType<Camera>().First().enabled = true;
|
||||
UpdateDialog.SetActive(false);
|
||||
UpdateConfirmationDialog.SetActive(false);
|
||||
UpdateCompletedDialog.SetActive(false);
|
||||
UpdateFailedDialog.SetActive(false);
|
||||
ProgressBar.value = 0;
|
||||
}
|
||||
|
||||
private void CheckForUpdates()
|
||||
{
|
||||
// check for updates and ask for permission to download if there are any
|
||||
@@ -94,7 +86,7 @@ namespace RothenburgAR.Updater
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateDialog.SetActive(true);
|
||||
UpdateState = UpdateState.UpdatesFound;
|
||||
|
||||
if (Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork)
|
||||
{
|
||||
@@ -102,7 +94,7 @@ namespace RothenburgAR.Updater
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateConfirmationDialog.SetActive(true);
|
||||
UpdateState = UpdateState.ConfirmationPending;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -174,8 +166,7 @@ namespace RothenburgAR.Updater
|
||||
- progressbar vllt ersetzen durch durchlaufdingens?
|
||||
*/
|
||||
|
||||
UpdateConfirmationDialog.SetActive(false);
|
||||
UpdateFailedDialog.SetActive(false);
|
||||
UpdateState = UpdateState.Downloading;
|
||||
|
||||
if (VersionAnswer == null)
|
||||
{
|
||||
@@ -279,7 +270,7 @@ namespace RothenburgAR.Updater
|
||||
var usedFileList = new Dictionary<string, FileDownloadInfo>();
|
||||
GenerateUsedFileList(usedFileList);
|
||||
|
||||
ProgressBar.maxValue = usedFileList.Count;
|
||||
MaxProgress = usedFileList.Count;
|
||||
foreach (var file in usedFileList)
|
||||
{
|
||||
var fileInfo = file.Value;
|
||||
@@ -299,8 +290,7 @@ namespace RothenburgAR.Updater
|
||||
deletedData.ForEach(d => DeleteExhibition(d));
|
||||
|
||||
CleanupMediaFiles();
|
||||
UpdateCompletedDialog.SetActive(true);
|
||||
StartCoroutine(LoadMainSceneAfterTime());
|
||||
UpdatesCompleted();
|
||||
}
|
||||
|
||||
private void GenerateUsedFileList(Dictionary<string, FileDownloadInfo> downloadList)
|
||||
@@ -404,7 +394,7 @@ namespace RothenburgAR.Updater
|
||||
{
|
||||
var subfiles = subfilesHeader.Split(new string[1] { ";;" }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||
|
||||
ProgressBar.maxValue += subfiles.Count(subfileName => !data.Keys.Contains(Path.Combine(info.directory, subfileName)));
|
||||
MaxProgress += subfiles.Count(subfileName => !data.Keys.Contains(Path.Combine(info.directory, subfileName)));
|
||||
|
||||
foreach (var subfileName in subfiles)
|
||||
{
|
||||
@@ -423,7 +413,7 @@ namespace RothenburgAR.Updater
|
||||
}
|
||||
|
||||
Debug.Log(string.Format("{1}-DONE with {0}", url, Time.realtimeSinceStartup));
|
||||
ProgressBar.value += 1;
|
||||
CurrentProgress += 1;
|
||||
}
|
||||
|
||||
private string GenerateETag(string filepath)
|
||||
@@ -473,20 +463,13 @@ namespace RothenburgAR.Updater
|
||||
http.Request.isHttpError,
|
||||
http.Request.responseCode));
|
||||
|
||||
UpdateDialog.SetActive(true);
|
||||
UpdateFailedDialog.SetActive(true);
|
||||
UpdateState = UpdateState.Failed;
|
||||
}
|
||||
|
||||
public IEnumerator LoadMainSceneAfterTime()
|
||||
public void UpdatesCompleted()
|
||||
{
|
||||
Debug.Log("Loading mainScene in " + afterDownloadWaitTime + "s");
|
||||
yield return new WaitForSecondsRealtime(afterDownloadWaitTime);
|
||||
LoadMainScene();
|
||||
}
|
||||
|
||||
public void LoadMainScene()
|
||||
{
|
||||
UnityEngine.SceneManagement.SceneManager.LoadScene("mainScene");
|
||||
//TODO force switch to UpdaterView when update needs to be applied
|
||||
UpdateState = UpdateState.Completed;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user