From a36abc5a80b9b064baa787c0663735c03ffab17d Mon Sep 17 00:00:00 2001 From: desktop-maesty/steve Date: Sat, 7 Apr 2018 18:43:16 +1000 Subject: [PATCH] Added Fungus Signals for MenuDialog becoming active or inactive --- .../Fungus/Scripts/Components/MenuDialog.cs | 11 ++++++-- Assets/Fungus/Scripts/Signals/MenuSignals.cs | 26 +++++++++++++++++++ .../Scripts/Signals/MenuSignals.cs.meta | 13 ++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 Assets/Fungus/Scripts/Signals/MenuSignals.cs create mode 100644 Assets/Fungus/Scripts/Signals/MenuSignals.cs.meta diff --git a/Assets/Fungus/Scripts/Components/MenuDialog.cs b/Assets/Fungus/Scripts/Components/MenuDialog.cs index 9462276c..c530f7a3 100644 --- a/Assets/Fungus/Scripts/Components/MenuDialog.cs +++ b/Assets/Fungus/Scripts/Components/MenuDialog.cs @@ -176,6 +176,10 @@ namespace Fungus { StopAllCoroutines(); + //if something was shown notify that we are ending + if(nextOptionIndex != 0) + MenuSignals.DoMenuEnd(this); + nextOptionIndex = 0; var optionButtons = CachedButtons; @@ -292,8 +296,12 @@ namespace Fungus if (nextOptionIndex >= CachedButtons.Length) return false; - var button = cachedButtons[nextOptionIndex]; + //if first option notify that a menu has started + if(nextOptionIndex == 0) + MenuSignals.DoMenuStart(this); + var button = cachedButtons[nextOptionIndex]; + //move forward for next call nextOptionIndex++; @@ -314,7 +322,6 @@ namespace Fungus } button.onClick.AddListener(action); - return true; } diff --git a/Assets/Fungus/Scripts/Signals/MenuSignals.cs b/Assets/Fungus/Scripts/Signals/MenuSignals.cs new file mode 100644 index 00000000..0f5e8c1f --- /dev/null +++ b/Assets/Fungus/Scripts/Signals/MenuSignals.cs @@ -0,0 +1,26 @@ +namespace Fungus +{ + /// + /// Menu change event signalling system. + /// You can use this to be notified about various events, actions and state changes of the Menu system. + /// + public static class MenuSignals + { + #region Public members + + /// + /// MenuStart signal. Sent when a Menu is being shown, where previously there wasn't one. + /// + public static event MenuStartHandler OnMenuStart; + public delegate void MenuStartHandler(MenuDialog menu); + public static void DoMenuStart(MenuDialog menu) { if (OnMenuStart != null) OnMenuStart(menu); } + + /// + /// MenuEnd signal. Sent when a Menu is no longer being shown, where previously there was one. + /// + public static event MenuEndHandler OnMenuEnd; + public delegate void MenuEndHandler(MenuDialog menu); + public static void DoMenuEnd(MenuDialog menu) { if (OnMenuEnd != null) OnMenuEnd(menu); } + #endregion + } +} diff --git a/Assets/Fungus/Scripts/Signals/MenuSignals.cs.meta b/Assets/Fungus/Scripts/Signals/MenuSignals.cs.meta new file mode 100644 index 00000000..647e3fbf --- /dev/null +++ b/Assets/Fungus/Scripts/Signals/MenuSignals.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: a233507ebbe704141b29dd39f6428b21 +timeCreated: 1523089248 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: