Browse Source

Merge pull request #173 from FungusGames/hide-commands-property

Added a Hide Commands property to Flowchart
master
Chris Gregan 10 years ago
parent
commit
0297c4d811
  1. 6
      Assets/Fungus/Flowchart/Editor/FlowchartEditor.cs
  2. 16
      Assets/Fungus/Flowchart/Scripts/Flowchart.cs

6
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"))

16
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<string> hideCommands = new List<string>();
/**
* 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;
}

Loading…
Cancel
Save