Browse Source

Added interactable property to Menu command

Allows you to add Menu options that are not selectable by the user
(e.g. they option is not available yet).
https://trello.com/c/bFjmGfBc
master
chrisgregan 9 years ago
parent
commit
04aec28426
  1. 5
      Assets/Fungus/Narrative/Scripts/Commands/Menu.cs
  2. 5
      Assets/Fungus/Narrative/Scripts/MenuDialog.cs

5
Assets/Fungus/Narrative/Scripts/Commands/Menu.cs

@ -26,6 +26,9 @@ namespace Fungus
[Tooltip("Hide this option if the target block has been executed previously")] [Tooltip("Hide this option if the target block has been executed previously")]
public bool hideIfVisited; public bool hideIfVisited;
[Tooltip("If false, the menu option will be displayed but will not be selectable")]
public BooleanData interactable = new BooleanData(true);
[Tooltip("A custom Menu Dialog to use to display this menu. All subsequent Menu commands will use this dialog.")] [Tooltip("A custom Menu Dialog to use to display this menu. All subsequent Menu commands will use this dialog.")]
public MenuDialog setMenuDialog; public MenuDialog setMenuDialog;
@ -50,7 +53,7 @@ namespace Fungus
{ {
menuDialog.gameObject.SetActive(true); menuDialog.gameObject.SetActive(true);
string displayText = text; string displayText = text;
menuDialog.AddOption(displayText, targetBlock); menuDialog.AddOption(displayText, interactable, targetBlock);
} }
} }

5
Assets/Fungus/Narrative/Scripts/MenuDialog.cs

@ -91,9 +91,8 @@ namespace Fungus
} }
} }
public virtual bool AddOption(string text, Block targetBlock) public virtual bool AddOption(string text, bool interactable, Block targetBlock)
{ {
bool addedOption = false; bool addedOption = false;
foreach (Button button in cachedButtons) foreach (Button button in cachedButtons)
{ {
@ -101,6 +100,8 @@ namespace Fungus
{ {
button.gameObject.SetActive(true); button.gameObject.SetActive(true);
button.interactable = interactable;
Text textComponent = button.GetComponentInChildren<Text>(); Text textComponent = button.GetComponentInChildren<Text>();
if (textComponent != null) if (textComponent != null)
{ {

Loading…
Cancel
Save