diff --git a/Assets/Fungus/Flowchart/Editor/FlowchartEditor.cs b/Assets/Fungus/Flowchart/Editor/FlowchartEditor.cs index e5e24869..1a9009a5 100644 --- a/Assets/Fungus/Flowchart/Editor/FlowchartEditor.cs +++ b/Assets/Fungus/Flowchart/Editor/FlowchartEditor.cs @@ -25,6 +25,7 @@ namespace Fungus protected SerializedProperty saveSelectionProp; protected SerializedProperty localizationIdProp; protected SerializedProperty variablesProp; + protected SerializedProperty hideCommandsProp; protected Texture2D addTexture; @@ -37,6 +38,7 @@ namespace Fungus saveSelectionProp = serializedObject.FindProperty("saveSelection"); localizationIdProp = serializedObject.FindProperty("localizationId"); variablesProp = serializedObject.FindProperty("variables"); + hideCommandsProp = serializedObject.FindProperty("hideCommands"); addTexture = Resources.Load("Icons/add_small") as Texture2D; } @@ -56,6 +58,10 @@ namespace Fungus EditorGUILayout.PropertyField(saveSelectionProp); EditorGUILayout.PropertyField(localizationIdProp); + // Show list of commands to hide in Add Command menu + ReorderableListGUI.Title(new GUIContent(hideCommandsProp.displayName, hideCommandsProp.tooltip)); + ReorderableListGUI.ListField(hideCommandsProp); + GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Flowchart Window")) diff --git a/Assets/Fungus/Flowchart/Scripts/Flowchart.cs b/Assets/Fungus/Flowchart/Scripts/Flowchart.cs index 2178e1b1..c0c8fe49 100644 --- a/Assets/Fungus/Flowchart/Scripts/Flowchart.cs +++ b/Assets/Fungus/Flowchart/Scripts/Flowchart.cs @@ -124,6 +124,12 @@ namespace Fungus [Tooltip("Unique identifier for this flowchart in localized string keys. If no id is specified then the name of the Flowchart object will be used.")] public string localizationId = ""; + /** + * List of commands to hide in the Add Command menu. Use this to restrict the set of commands available when editing a Flowchart. + */ + [Tooltip("List of commands to hide in the Add Command menu. Use this to restrict the set of commands available when editing a Flowchart.")] + public List hideCommands = new List(); + /** * Cached list of flowchart objects in the scene for fast lookup */ @@ -843,6 +849,16 @@ namespace Fungus */ public virtual bool IsCommandSupported(CommandInfoAttribute commandInfo) { + foreach (string key in hideCommands) + { + // Match on category or command name (case insensitive) + if (String.Compare(commandInfo.Category, key, StringComparison.OrdinalIgnoreCase) == 0 || + String.Compare(commandInfo.CommandName, key, StringComparison.OrdinalIgnoreCase) == 0) + { + return false; + } + } + return true; }