From 3f9162eb13b7002dc0f793f3d3bbd8e5c1931874 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Wed, 6 Apr 2016 16:48:45 +0100 Subject: [PATCH] Fix API change for OnLevelWasLoaded() event --- Assets/Fungus/Flowchart/Scripts/Flowchart.cs | 18 ++++++++++++++++-- .../Fungus/Narrative/Scripts/Localization.cs | 14 ++++++++++++++ .../Fungus/Thirdparty/LeanTween/LeanTween.cs | 16 +++++++++++++++- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/Assets/Fungus/Flowchart/Scripts/Flowchart.cs b/Assets/Fungus/Flowchart/Scripts/Flowchart.cs index c3ef4056..246c4eb7 100644 --- a/Assets/Fungus/Flowchart/Scripts/Flowchart.cs +++ b/Assets/Fungus/Flowchart/Scripts/Flowchart.cs @@ -183,12 +183,26 @@ namespace Fungus return maxId + 1; } - protected virtual void OnLevelWasLoaded(int level) + #if UNITY_5_4_OR_NEWER + protected virtual void Awake() + { + UnityEngine.SceneManagement.SceneManager.activeSceneChanged += (A, B) => { + LevelWasLoaded(); + }; + } + #else + public virtual void OnLevelWasLoaded(int level) + { + LevelWasLoaded(); + } + #endif + + protected virtual void LevelWasLoaded() { // Reset the flag for checking for an event system as there may not be one in the newly loaded scene. eventSystemPresent = false; } - + protected virtual void Start() { CheckEventSystem(); diff --git a/Assets/Fungus/Narrative/Scripts/Localization.cs b/Assets/Fungus/Narrative/Scripts/Localization.cs index 71925de2..c96f2da5 100644 --- a/Assets/Fungus/Narrative/Scripts/Localization.cs +++ b/Assets/Fungus/Narrative/Scripts/Localization.cs @@ -59,7 +59,21 @@ namespace Fungus protected bool initialized; + #if UNITY_5_4_OR_NEWER + protected virtual void Awake() + { + UnityEngine.SceneManagement.SceneManager.activeSceneChanged += (A, B) => { + LevelWasLoaded(); + }; + } + #else public virtual void OnLevelWasLoaded(int level) + { + LevelWasLoaded(); + } + #endif + + protected virtual void LevelWasLoaded() { // Check if a language has been selected using the Set Language command in a previous scene. if (SetLanguage.mostRecentLanguage != "") diff --git a/Assets/Fungus/Thirdparty/LeanTween/LeanTween.cs b/Assets/Fungus/Thirdparty/LeanTween/LeanTween.cs index 7a6478a7..8e4cee38 100644 --- a/Assets/Fungus/Thirdparty/LeanTween/LeanTween.cs +++ b/Assets/Fungus/Thirdparty/LeanTween/LeanTween.cs @@ -1346,7 +1346,21 @@ public void Update(){ LeanTween.update(); } -public void OnLevelWasLoaded( int lvl ){ +#if UNITY_5_4_OR_NEWER +protected void Awake() +{ + UnityEngine.SceneManagement.SceneManager.activeSceneChanged += (A, B) => { + LevelWasLoaded(); + }; +} +#else +protected void OnLevelWasLoaded(int level) +{ + LevelWasLoaded(); +} +#endif + +public void LevelWasLoaded(){ // Debug.Log("reseting gui"); LTGUI.reset(); }