From 04aec28426b5ae8c47b3d7063dc8a2bcf402160a Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Wed, 12 Aug 2015 14:12:52 +0100 Subject: [PATCH] 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 --- Assets/Fungus/Narrative/Scripts/Commands/Menu.cs | 5 ++++- Assets/Fungus/Narrative/Scripts/MenuDialog.cs | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Assets/Fungus/Narrative/Scripts/Commands/Menu.cs b/Assets/Fungus/Narrative/Scripts/Commands/Menu.cs index 79f6e456..ef62caff 100644 --- a/Assets/Fungus/Narrative/Scripts/Commands/Menu.cs +++ b/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")] 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.")] public MenuDialog setMenuDialog; @@ -50,7 +53,7 @@ namespace Fungus { menuDialog.gameObject.SetActive(true); string displayText = text; - menuDialog.AddOption(displayText, targetBlock); + menuDialog.AddOption(displayText, interactable, targetBlock); } } diff --git a/Assets/Fungus/Narrative/Scripts/MenuDialog.cs b/Assets/Fungus/Narrative/Scripts/MenuDialog.cs index c506ca1c..36528e84 100644 --- a/Assets/Fungus/Narrative/Scripts/MenuDialog.cs +++ b/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; foreach (Button button in cachedButtons) { @@ -101,6 +100,8 @@ namespace Fungus { button.gameObject.SetActive(true); + button.interactable = interactable; + Text textComponent = button.GetComponentInChildren(); if (textComponent != null) {