|
|
@ -264,13 +264,30 @@ namespace Fungus.EditorUtils |
|
|
|
|
|
|
|
|
|
|
|
EditorApplication.update += OnEditorUpdate; |
|
|
|
EditorApplication.update += OnEditorUpdate; |
|
|
|
Undo.undoRedoPerformed += Undo_ForceRepaint; |
|
|
|
Undo.undoRedoPerformed += Undo_ForceRepaint; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if UNITY_2017_4_OR_NEWER |
|
|
|
|
|
|
|
EditorApplication.playModeStateChanged += EditorApplication_playModeStateChanged; |
|
|
|
|
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected virtual void OnDisable() |
|
|
|
protected virtual void OnDisable() |
|
|
|
{ |
|
|
|
{ |
|
|
|
EditorApplication.update -= OnEditorUpdate; |
|
|
|
EditorApplication.update -= OnEditorUpdate; |
|
|
|
Undo.undoRedoPerformed -= Undo_ForceRepaint; |
|
|
|
Undo.undoRedoPerformed -= Undo_ForceRepaint; |
|
|
|
|
|
|
|
#if UNITY_2017_4_OR_NEWER |
|
|
|
|
|
|
|
EditorApplication.playModeStateChanged -= EditorApplication_playModeStateChanged; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if UNITY_2017_4_OR_NEWER |
|
|
|
|
|
|
|
private void EditorApplication_playModeStateChanged(PlayModeStateChange obj) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
//force null so it can refresh context on the other side of the context |
|
|
|
|
|
|
|
flowchart = null; |
|
|
|
|
|
|
|
prevFlowchart = null; |
|
|
|
|
|
|
|
blockInspector = null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
protected void Undo_ForceRepaint() |
|
|
|
protected void Undo_ForceRepaint() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -336,6 +353,7 @@ namespace Fungus.EditorUtils |
|
|
|
if (flowchart == null) |
|
|
|
if (flowchart == null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
blocks = new Block[0]; |
|
|
|
blocks = new Block[0]; |
|
|
|
|
|
|
|
filteredBlocks = new Block[0]; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
@ -347,6 +365,8 @@ namespace Fungus.EditorUtils |
|
|
|
|
|
|
|
|
|
|
|
protected virtual void OnInspectorUpdate() |
|
|
|
protected virtual void OnInspectorUpdate() |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (HandleFlowchartSelectionChange()) return; |
|
|
|
|
|
|
|
|
|
|
|
// Ensure the Block Inspector is always showing the currently selected block |
|
|
|
// Ensure the Block Inspector is always showing the currently selected block |
|
|
|
var flowchart = GetFlowchart(); |
|
|
|
var flowchart = GetFlowchart(); |
|
|
|
if (flowchart == null || AnyNullBLocks()) |
|
|
|
if (flowchart == null || AnyNullBLocks()) |
|
|
@ -450,13 +470,22 @@ namespace Fungus.EditorUtils |
|
|
|
{ |
|
|
|
{ |
|
|
|
filterStale = false; |
|
|
|
filterStale = false; |
|
|
|
//reset all |
|
|
|
//reset all |
|
|
|
foreach (var item in filteredBlocks) |
|
|
|
for (int i = 0; filteredBlocks != null && i < filteredBlocks.Length; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
item.IsFiltered = false; |
|
|
|
if(filteredBlocks[i] != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
filteredBlocks[i].IsFiltered = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var nullCount = filteredBlocks.Count(x => x == null); |
|
|
|
|
|
|
|
if (nullCount > 0 && nullCount != filteredBlocks.Length) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Debug.LogWarning("Null block found in filteredBlocks. May be a symptom of an underlying issue"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//gather new |
|
|
|
//gather new |
|
|
|
filteredBlocks = blocks.Where(block => block.BlockName.ToLower().Contains(searchString.ToLower())).ToArray(); |
|
|
|
filteredBlocks = blocks.Where(block => block.BlockName.IndexOf(searchString, StringComparison.OrdinalIgnoreCase) >= 0).ToArray(); |
|
|
|
|
|
|
|
|
|
|
|
//update filteredness |
|
|
|
//update filteredness |
|
|
|
foreach (var item in filteredBlocks) |
|
|
|
foreach (var item in filteredBlocks) |
|
|
@ -573,9 +602,16 @@ namespace Fungus.EditorUtils |
|
|
|
{ |
|
|
|
{ |
|
|
|
mouseDownSelectionState.AddRange(flowchart.SelectedBlocks); |
|
|
|
mouseDownSelectionState.AddRange(flowchart.SelectedBlocks); |
|
|
|
flowchart.ClearSelectedBlocks(); |
|
|
|
flowchart.ClearSelectedBlocks(); |
|
|
|
foreach (var item in mouseDownSelectionState) |
|
|
|
for (int i = 0; i < mouseDownSelectionState.Count; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
item.IsControlSelected = true; |
|
|
|
if (mouseDownSelectionState[i] != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
mouseDownSelectionState[i].IsControlSelected = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Debug.LogWarning("Null block found in mouseDownSelectionState. May be a symptom of an underlying issue"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -633,7 +669,22 @@ namespace Fungus.EditorUtils |
|
|
|
blockInspector = null; |
|
|
|
blockInspector = null; |
|
|
|
prevFlowchart = flowchart; |
|
|
|
prevFlowchart = flowchart; |
|
|
|
executingBlocks.ClearAll(); |
|
|
|
executingBlocks.ClearAll(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//attempt to defilter previous, if due to scene change these will be null |
|
|
|
|
|
|
|
// the regular filter updates will still occur within UpdateBlockCollection |
|
|
|
|
|
|
|
for (int i = 0; i < filteredBlocks.Length; i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (filteredBlocks[i] != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
filteredBlocks[i].IsFiltered = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UpdateBlockCollection(); |
|
|
|
UpdateBlockCollection(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(flowchart != null) |
|
|
|
|
|
|
|
flowchart.ReverseUpdateSelectedCache();//becomes reverse restore selected cache |
|
|
|
|
|
|
|
|
|
|
|
Repaint(); |
|
|
|
Repaint(); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|