Browse Source

Add quick add block button to Menu Command block select

Closes #211
master
Steve Halliwell 5 years ago
parent
commit
e51ab9d688
  1. 9
      Assets/Fungus/Scripts/Editor/FlowchartWindow.cs
  2. 18
      Assets/Fungus/Scripts/Editor/MenuEditor.cs

9
Assets/Fungus/Scripts/Editor/FlowchartWindow.cs

@ -1534,6 +1534,15 @@ namespace Fungus.EditorUtils
return newBlock;
}
public Block CreateBlockSuppressSelect(Flowchart flowchart, Vector2 position)
{
Block newBlock = flowchart.CreateBlock(position);
UpdateBlockCollection();
Undo.RegisterCreatedObjectUndo(newBlock, "New Block");
return newBlock;
}
protected virtual void DrawConnections(Block block)
{
if (block == null)

18
Assets/Fungus/Scripts/Editor/MenuEditor.cs

@ -43,12 +43,26 @@ namespace Fungus.EditorUtils
EditorGUILayout.PropertyField(textProp);
EditorGUILayout.PropertyField(descriptionProp);
EditorGUILayout.BeginHorizontal();
BlockEditor.BlockField(targetBlockProp,
new GUIContent("Target Block", "Block to call when option is selected"),
new GUIContent("<None>"),
flowchart);
const int popupWidth = 17;
if(targetBlockProp.objectReferenceValue == null && GUILayout.Button("+",GUILayout.MaxWidth(popupWidth)))
{
var fw = EditorWindow.GetWindow<FlowchartWindow>();
var t = (Menu)target;
var activeFlowchart = t.GetFlowchart();
var newBlock = fw.CreateBlockSuppressSelect(activeFlowchart, t.ParentBlock._NodeRect.position - Vector2.down * 60);
targetBlockProp.objectReferenceValue = newBlock;
activeFlowchart.SelectedBlock = t.ParentBlock;
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.PropertyField(hideIfVisitedProp);
EditorGUILayout.PropertyField(interactableProp);
EditorGUILayout.PropertyField(setMenuDialogProp);

Loading…
Cancel
Save