Browse Source

Merge pull request #670 from stevehalliwell/MenuSignals

Added Fungus Signals for MenuDialog becoming active or inactive
master
Chris Gregan 7 years ago committed by GitHub
parent
commit
56664223b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      Assets/Fungus/Scripts/Components/MenuDialog.cs
  2. 26
      Assets/Fungus/Scripts/Signals/MenuSignals.cs
  3. 13
      Assets/Fungus/Scripts/Signals/MenuSignals.cs.meta

11
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;
}

26
Assets/Fungus/Scripts/Signals/MenuSignals.cs

@ -0,0 +1,26 @@
namespace Fungus
{
/// <summary>
/// Menu change event signalling system.
/// You can use this to be notified about various events, actions and state changes of the Menu system.
/// </summary>
public static class MenuSignals
{
#region Public members
/// <summary>
/// MenuStart signal. Sent when a Menu is being shown, where previously there wasn't one.
/// </summary>
public static event MenuStartHandler OnMenuStart;
public delegate void MenuStartHandler(MenuDialog menu);
public static void DoMenuStart(MenuDialog menu) { if (OnMenuStart != null) OnMenuStart(menu); }
/// <summary>
/// MenuEnd signal. Sent when a Menu is no longer being shown, where previously there was one.
/// </summary>
public static event MenuEndHandler OnMenuEnd;
public delegate void MenuEndHandler(MenuDialog menu);
public static void DoMenuEnd(MenuDialog menu) { if (OnMenuEnd != null) OnMenuEnd(menu); }
#endregion
}
}

13
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:
Loading…
Cancel
Save