Implemented ApplyUpdates method to reload the scene after updates were downloaded

This commit is contained in:
2019-01-05 18:42:30 +01:00
parent 8b24d4660e
commit a9bf767f8d
6 changed files with 56 additions and 9 deletions

View File

@@ -2430,7 +2430,7 @@ MonoBehaviour:
m_PersistentCalls: m_PersistentCalls:
m_Calls: m_Calls:
- m_Target: {fileID: 114612701476717838} - m_Target: {fileID: 114612701476717838}
m_MethodName: ExitView m_MethodName: ApplyUpdates
m_Mode: 1 m_Mode: 1
m_Arguments: m_Arguments:
m_ObjectArgument: {fileID: 0} m_ObjectArgument: {fileID: 0}

View File

@@ -63,5 +63,10 @@ namespace RothenburgAR
" Exhibitions of Path " + currentPaths + " of " + maxPaths + " paths.</color>"); " Exhibitions of Path " + currentPaths + " of " + maxPaths + " paths.</color>");
}); });
} }
private void OnDestroy()
{
VuforiaARController.Instance.UnregisterVuforiaInitializedCallback(InitializeData);
}
} }
} }

View File

@@ -1,4 +1,5 @@
using UnityEngine; using RothenburgAR.UI;
using UnityEngine;
namespace RothenburgAR.Common namespace RothenburgAR.Common
{ {
@@ -32,7 +33,7 @@ namespace RothenburgAR.Common
{ {
if (_instance == null) if (_instance == null)
{ {
_instance = (T) FindObjectOfType(typeof(T)); _instance = (T)FindObjectOfType(typeof(T));
if (FindObjectsOfType(typeof(T)).Length > 1) if (FindObjectsOfType(typeof(T)).Length > 1)
{ {
@@ -68,6 +69,12 @@ namespace RothenburgAR.Common
private static bool applicationIsQuitting = false; private static bool applicationIsQuitting = false;
public virtual void ResetInstance()
{
Destroy(_instance.gameObject);
_instance = null;
}
/// <summary> /// <summary>
/// When Unity quits, it destroys objects in a random order. /// When Unity quits, it destroys objects in a random order.
/// In principle, a Singleton is only destroyed when application quits. /// In principle, a Singleton is only destroyed when application quits.
@@ -77,6 +84,10 @@ namespace RothenburgAR.Common
/// So, this was made to be sure we're not creating that buggy ghost object. /// So, this was made to be sure we're not creating that buggy ghost object.
/// </summary> /// </summary>
public void OnDestroy() public void OnDestroy()
{
}
private void OnApplicationQuit()
{ {
applicationIsQuitting = true; applicationIsQuitting = true;
} }

View File

@@ -1,8 +1,8 @@
using System.IO; using System.IO;
using Newtonsoft.Json; using Newtonsoft.Json;
using RothenburgAR.UI; using RothenburgAR.Common;
namespace RothenburgAR.Common namespace RothenburgAR.UI
{ {
class SettingsManager : Singleton<SettingsManager> class SettingsManager : Singleton<SettingsManager>
{ {

View File

@@ -1,5 +1,9 @@
using RothenburgAR.Updater; using RothenburgAR.Exhibition;
using RothenburgAR.PointOfInterest;
using RothenburgAR.Updater;
using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.SceneManagement;
namespace RothenburgAR.UI namespace RothenburgAR.UI
{ {
@@ -11,18 +15,26 @@ namespace RothenburgAR.UI
public GameObject UpdateCompletedDialog; public GameObject UpdateCompletedDialog;
public GameObject UpdateFailedDialog; public GameObject UpdateFailedDialog;
private bool allowAbort = true;
private UpdateState lastUpdateState = UpdateState.UpdatesFound; private UpdateState lastUpdateState = UpdateState.UpdatesFound;
private void Start() private void Start()
{ {
UIManager.Instance.StartingUp = false;
UpdateDialog.SetActive(true); UpdateDialog.SetActive(true);
UpdateConfirmationDialog.SetActive(false); UpdateConfirmationDialog.SetActive(false);
UpdateCompletedDialog.SetActive(false); UpdateCompletedDialog.SetActive(false);
UpdateFailedDialog.SetActive(false); UpdateFailedDialog.SetActive(false);
ProgressBar.value = 0; ProgressBar.value = 0;
ProgressBar.maxValue = 1; ProgressBar.maxValue = 1;
if (UIManager.Instance.StartingUp)
{
allowAbort = false;
//TODO disable all ExitView() calls in UI and ensure they are not enabled otherwise
}
UIManager.Instance.StartingUp = false;
} }
private void Update() private void Update()
@@ -53,7 +65,7 @@ namespace RothenburgAR.UI
case UpdateState.Completed: case UpdateState.Completed:
UpdateCompletedDialog.SetActive(true); UpdateCompletedDialog.SetActive(true);
//TODO add "apply upgrades" button or sth that Destroys all DontDestroyOnLoads and reloads the scene, use AppInitializerBehaviour for that //TODO add "apply upgrades" button which Destroys all DontDestroyOnLoads and reloads the scene
break; break;
case UpdateState.Failed: case UpdateState.Failed:
@@ -72,5 +84,24 @@ namespace RothenburgAR.UI
UIManager.Instance.SwitchToView(ViewName.ARView); UIManager.Instance.SwitchToView(ViewName.ARView);
} }
public void ApplyUpdates()
{
//DisplayManager.ResetInstance();
LanguageManager.Instance.ResetInstance();
InputManager.Instance.ResetInstance();
UIManager.Instance.ResetInstance();
UpdateManager.Instance.ResetInstance();
SettingsManager.Instance.ResetInstance();
PoiDataManager.Instance.ResetInstance();
ExhibitionManager.Instance.ResetInstance();
UIColorSchemeManager.Instance.ResetInstance();
FontsizeManager.Instance.ResetInstance();
SceneManager.LoadScene("mainScene");
}
} }
} }