From 1bbb8da1c3bd8dc73c20158a2ab199ed9dbd9ed7 Mon Sep 17 00:00:00 2001 From: desktop-maesty/steve Date: Sat, 15 Jul 2017 10:43:39 +1000 Subject: [PATCH] Added logic to handle destroying the blockdrawers when the target flowchart changes underneath them. -A nuclear option perhaps but solves Prefab Variable Dereferencing #618 --- .../Fungus/Scripts/Editor/FlowchartWindow.cs | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs index 1840308b..faf82dc0 100644 --- a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs +++ b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs @@ -130,7 +130,7 @@ namespace Fungus.EditorUtils protected Block[] filteredBlocks; protected int blockPopupSelection = -1; protected Vector2 popupScroll; - protected Flowchart flowchart; + protected Flowchart flowchart, prevFlowchart; protected Block[] blocks; protected Block dragBlock; protected static FungusState fungusState; @@ -334,6 +334,14 @@ namespace Fungus.EditorUtils return; } + //target has changed, so clear the blockinspector + if (flowchart != prevFlowchart) + { + blockInspector = null; + prevFlowchart = flowchart; + return; + } + DeleteBlocks(); blocks = flowchart.GetComponents(); @@ -363,7 +371,17 @@ namespace Fungus.EditorUtils } // Draw toolbar, search popup, and variables window - DrawOverlay(Event.current); + // need try catch here as we are now invalidating the drawer if the target flowchart + // has changed which makes unity GUILayouts upset and this function appears to + // actually get called partially outside our control + try + { + DrawOverlay(Event.current); + } + catch (Exception) + { + //Debug.Log("Failed to draw overlay in some way"); + } // Handle events for custom GUI base.HandleEvents(Event.current);