|
|
@ -34,6 +34,10 @@ namespace Fungus.EditorUtils |
|
|
|
|
|
|
|
|
|
|
|
protected Texture2D addTexture; |
|
|
|
protected Texture2D addTexture; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected Rect selectionBox; |
|
|
|
|
|
|
|
protected Vector2 startSelectionBoxPosition; |
|
|
|
|
|
|
|
protected List<Block> mouseDownSelectionState; |
|
|
|
|
|
|
|
|
|
|
|
[MenuItem("Tools/Fungus/Flowchart Window")] |
|
|
|
[MenuItem("Tools/Fungus/Flowchart Window")] |
|
|
|
static void Init() |
|
|
|
static void Init() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -120,7 +124,7 @@ namespace Fungus.EditorUtils |
|
|
|
// Delete any scheduled objects |
|
|
|
// Delete any scheduled objects |
|
|
|
foreach (var deleteBlock in deleteList) |
|
|
|
foreach (var deleteBlock in deleteList) |
|
|
|
{ |
|
|
|
{ |
|
|
|
bool isSelected = (flowchart.SelectedBlock == deleteBlock); |
|
|
|
bool isSelected = (flowchart.SelectedBlocks.Contains(deleteBlock)); |
|
|
|
|
|
|
|
|
|
|
|
var commandList = deleteBlock.CommandList; |
|
|
|
var commandList = deleteBlock.CommandList; |
|
|
|
foreach (var command in commandList) |
|
|
|
foreach (var command in commandList) |
|
|
@ -142,6 +146,9 @@ namespace Fungus.EditorUtils |
|
|
|
DrawFlowchartView(flowchart); |
|
|
|
DrawFlowchartView(flowchart); |
|
|
|
DrawOverlay(flowchart); |
|
|
|
DrawOverlay(flowchart); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Handle selection box events after block and overlay events |
|
|
|
|
|
|
|
HandleSelectionBox(flowchart); |
|
|
|
|
|
|
|
|
|
|
|
if (forceRepaintCount > 0) |
|
|
|
if (forceRepaintCount > 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Redraw on next frame to get crisp refresh rate |
|
|
|
// Redraw on next frame to get crisp refresh rate |
|
|
@ -248,18 +255,6 @@ namespace Fungus.EditorUtils |
|
|
|
|
|
|
|
|
|
|
|
GLDraw.BeginGroup(scriptViewRect); |
|
|
|
GLDraw.BeginGroup(scriptViewRect); |
|
|
|
|
|
|
|
|
|
|
|
if (Event.current.button == 0 && |
|
|
|
|
|
|
|
Event.current.type == EventType.MouseDown && |
|
|
|
|
|
|
|
!mouseOverVariables) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
flowchart.SelectedBlock = null; |
|
|
|
|
|
|
|
if (!EditorGUI.actionKey) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
flowchart.ClearSelectedCommands(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Selection.activeGameObject = flowchart.gameObject; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// The center of the Flowchart depends on the block positions and window dimensions, so we calculate it |
|
|
|
// The center of the Flowchart depends on the block positions and window dimensions, so we calculate it |
|
|
|
// here in the FlowchartWindow class and store it on the Flowchart object for use later. |
|
|
|
// here in the FlowchartWindow class and store it on the Flowchart object for use later. |
|
|
|
CalcFlowchartCenter(flowchart, blocks); |
|
|
|
CalcFlowchartCenter(flowchart, blocks); |
|
|
@ -280,6 +275,8 @@ namespace Fungus.EditorUtils |
|
|
|
BeginWindows(); |
|
|
|
BeginWindows(); |
|
|
|
|
|
|
|
|
|
|
|
windowBlockMap.Clear(); |
|
|
|
windowBlockMap.Clear(); |
|
|
|
|
|
|
|
bool useEvent = false; |
|
|
|
|
|
|
|
bool endDrag = false; |
|
|
|
for (int i = 0; i < blocks.Length; ++i) |
|
|
|
for (int i = 0; i < blocks.Length; ++i) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var block = blocks[i]; |
|
|
|
var block = blocks[i]; |
|
|
@ -297,28 +294,33 @@ namespace Fungus.EditorUtils |
|
|
|
tempRect.width = Mathf.Max(Mathf.Max(nodeWidthA, nodeWidthB), 120); |
|
|
|
tempRect.width = Mathf.Max(Mathf.Max(nodeWidthA, nodeWidthB), 120); |
|
|
|
tempRect.height = 40; |
|
|
|
tempRect.height = 40; |
|
|
|
|
|
|
|
|
|
|
|
if (Event.current.type == EventType.MouseDrag && dragWindowId == i) |
|
|
|
if (dragWindowId > -1 && flowchart.SelectedBlocks.Contains(block)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (Event.current.type == EventType.MouseDrag) |
|
|
|
{ |
|
|
|
{ |
|
|
|
tempRect.x += Event.current.delta.x; |
|
|
|
tempRect.x += Event.current.delta.x; |
|
|
|
tempRect.y += Event.current.delta.y; |
|
|
|
tempRect.y += Event.current.delta.y; |
|
|
|
|
|
|
|
|
|
|
|
forceRepaintCount = 6; |
|
|
|
forceRepaintCount = 6; |
|
|
|
|
|
|
|
useEvent = true; |
|
|
|
} |
|
|
|
} |
|
|
|
else if (Event.current.type == EventType.MouseUp && |
|
|
|
else if (Event.current.rawType == EventType.MouseUp) |
|
|
|
dragWindowId == i) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
Vector2 newPos = new Vector2(tempRect.x, tempRect.y); |
|
|
|
Vector2 newPos = new Vector2(tempRect.x, tempRect.y); |
|
|
|
|
|
|
|
tempRect.x = startDragPosition.x + (newPos.x - blocks[dragWindowId]._NodeRect.position.x); |
|
|
|
|
|
|
|
tempRect.y = startDragPosition.y + (newPos.y - blocks[dragWindowId]._NodeRect.position.y); |
|
|
|
|
|
|
|
|
|
|
|
tempRect.x = startDragPosition.x; |
|
|
|
block._NodeRect = tempRect; |
|
|
|
tempRect.y = startDragPosition.y; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Undo.RecordObject((Block)block, "Node Position"); |
|
|
|
Undo.RecordObject(block, "Node Position"); |
|
|
|
|
|
|
|
|
|
|
|
tempRect.x = newPos.x; |
|
|
|
tempRect.x = newPos.x; |
|
|
|
tempRect.y = newPos.y; |
|
|
|
tempRect.y = newPos.y; |
|
|
|
|
|
|
|
|
|
|
|
dragWindowId = -1; |
|
|
|
|
|
|
|
forceRepaintCount = 6; |
|
|
|
forceRepaintCount = 6; |
|
|
|
|
|
|
|
useEvent = true; |
|
|
|
|
|
|
|
endDrag = true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
block._NodeRect = tempRect; |
|
|
|
block._NodeRect = tempRect; |
|
|
@ -335,6 +337,13 @@ namespace Fungus.EditorUtils |
|
|
|
windowBlockMap.Add(block); |
|
|
|
windowBlockMap.Add(block); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dragWindowId = endDrag ? -1 : dragWindowId; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (useEvent) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Event.current.Use(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
EndWindows(); |
|
|
|
EndWindows(); |
|
|
|
|
|
|
|
|
|
|
|
// Draw Event Handler labels |
|
|
|
// Draw Event Handler labels |
|
|
@ -407,6 +416,23 @@ namespace Fungus.EditorUtils |
|
|
|
GLDraw.EndGroup(); |
|
|
|
GLDraw.EndGroup(); |
|
|
|
|
|
|
|
|
|
|
|
EditorZoomArea.End(); |
|
|
|
EditorZoomArea.End(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If event has yet to be used and user isn't multiselecting or panning, clear selection |
|
|
|
|
|
|
|
bool validModifier = Event.current.alt || GetAppendModifierDown(); |
|
|
|
|
|
|
|
if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && !validModifier) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Undo.RecordObject(flowchart, "Deselect"); |
|
|
|
|
|
|
|
flowchart.ClearSelectedCommands(); |
|
|
|
|
|
|
|
flowchart.ClearSelectedBlocks(); |
|
|
|
|
|
|
|
Selection.activeGameObject = flowchart.gameObject; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Draw selection box |
|
|
|
|
|
|
|
if (startSelectionBoxPosition.x >= 0 && startSelectionBoxPosition.y >= 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
GUI.Box(selectionBox, "", (GUIStyle) "SelectionRect"); |
|
|
|
|
|
|
|
forceRepaintCount = 6; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public virtual void CalcFlowchartCenter(Flowchart flowchart, Block[] blocks) |
|
|
|
public virtual void CalcFlowchartCenter(Flowchart flowchart, Block[] blocks) |
|
|
@ -436,6 +462,77 @@ namespace Fungus.EditorUtils |
|
|
|
flowchart.CenterPosition = center; |
|
|
|
flowchart.CenterPosition = center; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual void HandleSelectionBox(Flowchart flowchart) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (Event.current.button == 0 && Event.current.modifiers != EventModifiers.Alt && |
|
|
|
|
|
|
|
!(UnityEditor.Tools.current == Tool.View && UnityEditor.Tools.viewTool == ViewTool.Pan)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
switch (Event.current.type) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
case EventType.MouseDown: |
|
|
|
|
|
|
|
startSelectionBoxPosition = Event.current.mousePosition; |
|
|
|
|
|
|
|
mouseDownSelectionState = new List<Block>(flowchart.SelectedBlocks); |
|
|
|
|
|
|
|
Event.current.Use(); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case EventType.MouseDrag: |
|
|
|
|
|
|
|
if (startSelectionBoxPosition.x >= 0 && startSelectionBoxPosition.y >= 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var topLeft = Vector2.Min(startSelectionBoxPosition, Event.current.mousePosition); |
|
|
|
|
|
|
|
var bottomRight = Vector2.Max(startSelectionBoxPosition, Event.current.mousePosition); |
|
|
|
|
|
|
|
selectionBox = Rect.MinMaxRect(topLeft.x, topLeft.y, bottomRight.x, bottomRight.y); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Rect zoomSelectionBox = selectionBox; |
|
|
|
|
|
|
|
zoomSelectionBox.position -= flowchart.ScrollPos * flowchart.Zoom; |
|
|
|
|
|
|
|
zoomSelectionBox.position /= flowchart.Zoom; |
|
|
|
|
|
|
|
zoomSelectionBox.size /= flowchart.Zoom; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var block in flowchart.GetComponents<Block>()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (zoomSelectionBox.Overlaps(block._NodeRect)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (mouseDownSelectionState.Contains(block)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
flowchart.SelectedBlocks.Remove(block); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
flowchart.AddSelectedBlock(block); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (mouseDownSelectionState.Contains(block)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
flowchart.AddSelectedBlock(block); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
flowchart.SelectedBlocks.Remove(block); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Event.current.Use(); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Event.current.rawType == EventType.MouseUp) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
selectionBox.size = Vector2.zero; |
|
|
|
|
|
|
|
selectionBox.position = Vector2.one * -1; |
|
|
|
|
|
|
|
startSelectionBoxPosition = selectionBox.position; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var tempList = new List<Block>(flowchart.SelectedBlocks); |
|
|
|
|
|
|
|
flowchart.SelectedBlocks = mouseDownSelectionState; |
|
|
|
|
|
|
|
Undo.RecordObject(flowchart, "Select"); |
|
|
|
|
|
|
|
flowchart.SelectedBlocks = tempList; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (flowchart.SelectedBlock != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
SetBlockForInspector(flowchart, flowchart.SelectedBlock); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected virtual void PanAndZoom(Flowchart flowchart) |
|
|
|
protected virtual void PanAndZoom(Flowchart flowchart) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Right click to drag view |
|
|
|
// Right click to drag view |
|
|
@ -482,7 +579,7 @@ namespace Fungus.EditorUtils |
|
|
|
zoom = true; |
|
|
|
zoom = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (zoom) |
|
|
|
if (zoom && selectionBox.size == Vector2.zero) |
|
|
|
{ |
|
|
|
{ |
|
|
|
flowchart.Zoom -= Event.current.delta.y * 0.01f; |
|
|
|
flowchart.Zoom -= Event.current.delta.y * 0.01f; |
|
|
|
flowchart.Zoom = Mathf.Clamp(flowchart.Zoom, minZoomValue, maxZoomValue); |
|
|
|
flowchart.Zoom = Mathf.Clamp(flowchart.Zoom, minZoomValue, maxZoomValue); |
|
|
@ -532,22 +629,18 @@ namespace Fungus.EditorUtils |
|
|
|
protected virtual void SelectBlock(Flowchart flowchart, Block block) |
|
|
|
protected virtual void SelectBlock(Flowchart flowchart, Block block) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Select the block and also select currently executing command |
|
|
|
// Select the block and also select currently executing command |
|
|
|
ShowBlockInspector(flowchart); |
|
|
|
|
|
|
|
flowchart.SelectedBlock = block; |
|
|
|
flowchart.SelectedBlock = block; |
|
|
|
flowchart.ClearSelectedCommands(); |
|
|
|
SetBlockForInspector(flowchart, block); |
|
|
|
if (block.ActiveCommand != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
flowchart.AddSelectedCommand(block.ActiveCommand); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static Block CreateBlock(Flowchart flowchart, Vector2 position) |
|
|
|
public static Block CreateBlock(Flowchart flowchart, Vector2 position) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Block newBlock = flowchart.CreateBlock(position); |
|
|
|
Block newBlock = flowchart.CreateBlock(position); |
|
|
|
Undo.RegisterCreatedObjectUndo(newBlock, "New Block"); |
|
|
|
Undo.RegisterCreatedObjectUndo(newBlock, "New Block"); |
|
|
|
ShowBlockInspector(flowchart); |
|
|
|
|
|
|
|
flowchart.SelectedBlock = newBlock; |
|
|
|
// Use AddSelected instead of Select for when multiple blocks are duplicated |
|
|
|
flowchart.ClearSelectedCommands(); |
|
|
|
flowchart.AddSelectedBlock(newBlock); |
|
|
|
|
|
|
|
SetBlockForInspector(flowchart, newBlock); |
|
|
|
|
|
|
|
|
|
|
|
return newBlock; |
|
|
|
return newBlock; |
|
|
|
} |
|
|
|
} |
|
|
@ -582,6 +675,8 @@ namespace Fungus.EditorUtils |
|
|
|
// Check if might be start of a window drag |
|
|
|
// Check if might be start of a window drag |
|
|
|
if (Event.current.button == 0 && |
|
|
|
if (Event.current.button == 0 && |
|
|
|
Event.current.alt == false) |
|
|
|
Event.current.alt == false) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (!GetAppendModifierDown()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
dragWindowId = windowId; |
|
|
|
dragWindowId = windowId; |
|
|
|
|
|
|
|
|
|
|
@ -589,19 +684,42 @@ namespace Fungus.EditorUtils |
|
|
|
startDragPosition.y = block._NodeRect.y; |
|
|
|
startDragPosition.y = block._NodeRect.y; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Event.current.Use(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (windowId < windowBlockMap.Count) |
|
|
|
if (windowId < windowBlockMap.Count) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Undo.RecordObject(flowchart, "Select"); |
|
|
|
Undo.RecordObject(flowchart, "Select"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (GetAppendModifierDown()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (flowchart.SelectedBlocks.Contains(block)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
flowchart.SelectedBlocks.Remove(block); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
flowchart.AddSelectedBlock(block); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (flowchart.SelectedBlocks.Contains(block)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
SetBlockForInspector(flowchart, block); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
SelectBlock(flowchart, block); |
|
|
|
SelectBlock(flowchart, block); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
GUIUtility.keyboardControl = 0; // Fix for textarea not refeshing (change focus) |
|
|
|
GUIUtility.keyboardControl = 0; // Fix for textarea not refeshing (change focus) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool selected = false; |
|
|
|
bool selected = false; |
|
|
|
if (flowchart.SelectedBlock != null && |
|
|
|
if (flowchart.SelectedBlocks.Contains(block)) |
|
|
|
flowchart.SelectedBlock.Equals(block)) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
selected = true; |
|
|
|
selected = true; |
|
|
|
} |
|
|
|
} |
|
|
@ -670,7 +788,7 @@ namespace Fungus.EditorUtils |
|
|
|
|
|
|
|
|
|
|
|
nodeStyleCopy.normal.background = offTex; |
|
|
|
nodeStyleCopy.normal.background = offTex; |
|
|
|
GUI.backgroundColor = tintColor; |
|
|
|
GUI.backgroundColor = tintColor; |
|
|
|
GUI.Box(GUILayoutUtility.GetLastRect(), block.BlockName, nodeStyleCopy); |
|
|
|
GUI.Box(boxRect, block.BlockName, nodeStyleCopy); |
|
|
|
|
|
|
|
|
|
|
|
GUI.backgroundColor = Color.white; |
|
|
|
GUI.backgroundColor = Color.white; |
|
|
|
|
|
|
|
|
|
|
@ -683,10 +801,14 @@ namespace Fungus.EditorUtils |
|
|
|
|
|
|
|
|
|
|
|
if (Event.current.type == EventType.ContextClick) |
|
|
|
if (Event.current.type == EventType.ContextClick) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
flowchart.AddSelectedBlock(block); |
|
|
|
|
|
|
|
|
|
|
|
GenericMenu menu = new GenericMenu (); |
|
|
|
GenericMenu menu = new GenericMenu (); |
|
|
|
|
|
|
|
|
|
|
|
menu.AddItem(new GUIContent ("Duplicate"), false, DuplicateBlock, block); |
|
|
|
// Use a copy because flowchart.SelectedBlocks gets modified |
|
|
|
menu.AddItem(new GUIContent ("Delete"), false, DeleteBlock, block); |
|
|
|
var blockList = new List<Block>(flowchart.SelectedBlocks); |
|
|
|
|
|
|
|
menu.AddItem(new GUIContent ("Duplicate"), false, DuplicateBlocks, blockList); |
|
|
|
|
|
|
|
menu.AddItem(new GUIContent ("Delete"), false, DeleteBlocks, blockList); |
|
|
|
|
|
|
|
|
|
|
|
menu.ShowAsContext(); |
|
|
|
menu.ShowAsContext(); |
|
|
|
} |
|
|
|
} |
|
|
@ -804,17 +926,23 @@ namespace Fungus.EditorUtils |
|
|
|
GUI.Label(dotBRect, "", new GUIStyle("U2D.dragDotActive")); |
|
|
|
GUI.Label(dotBRect, "", new GUIStyle("U2D.dragDotActive")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void DeleteBlock(object obj) |
|
|
|
public static void DeleteBlocks(object obj) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var block = obj as Block; |
|
|
|
var blocks = obj as List<Block>; |
|
|
|
FlowchartWindow.deleteList.Add(block); |
|
|
|
blocks.ForEach(block => FlowchartWindow.deleteList.Add(block)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected static void DuplicateBlock(object obj) |
|
|
|
protected static void DuplicateBlocks(object obj) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var flowchart = GetFlowchart(); |
|
|
|
var flowchart = GetFlowchart(); |
|
|
|
Block block = obj as Block; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Undo.RecordObject(flowchart, "Select"); |
|
|
|
|
|
|
|
flowchart.ClearSelectedBlocks(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var blocks = obj as List<Block>; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var block in blocks) |
|
|
|
|
|
|
|
{ |
|
|
|
Vector2 newPosition = new Vector2(block._NodeRect.position.x + |
|
|
|
Vector2 newPosition = new Vector2(block._NodeRect.position.x + |
|
|
|
block._NodeRect.width + 20, |
|
|
|
block._NodeRect.width + 20, |
|
|
|
block._NodeRect.y); |
|
|
|
block._NodeRect.y); |
|
|
@ -864,6 +992,7 @@ namespace Fungus.EditorUtils |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected static void ShowBlockInspector(Flowchart flowchart) |
|
|
|
protected static void ShowBlockInspector(Flowchart flowchart) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -880,6 +1009,16 @@ namespace Fungus.EditorUtils |
|
|
|
EditorUtility.SetDirty(blockInspector); |
|
|
|
EditorUtility.SetDirty(blockInspector); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected static void SetBlockForInspector(Flowchart flowchart, Block block) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ShowBlockInspector(flowchart); |
|
|
|
|
|
|
|
flowchart.ClearSelectedCommands(); |
|
|
|
|
|
|
|
if (block.ActiveCommand != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
flowchart.AddSelectedCommand(block.ActiveCommand); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
/// Displays a temporary text alert in the center of the Flowchart window. |
|
|
|
/// Displays a temporary text alert in the center of the Flowchart window. |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
@ -891,5 +1030,10 @@ namespace Fungus.EditorUtils |
|
|
|
window.ShowNotification(new GUIContent(notificationText)); |
|
|
|
window.ShowNotification(new GUIContent(notificationText)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual bool GetAppendModifierDown() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return Event.current.shift || EditorGUI.actionKey; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |