From d7ab327cc2d9f649de66e8cf56cf578a213b8ca6 Mon Sep 17 00:00:00 2001 From: desktop-maesty/steve Date: Mon, 7 Jan 2019 21:30:35 +1000 Subject: [PATCH] FlowchartWindow checks for staleness of EventHandler, Block header info and Flowchart header info --- Assets/Fungus/Scripts/Editor/BlockEditor.cs | 17 +++++++++++++++++ Assets/Fungus/Scripts/Editor/FlowchartEditor.cs | 13 ++++++++++++- Assets/Fungus/Scripts/Editor/FlowchartWindow.cs | 12 ++++++++++++ .../EventSelectorPopupWindowContent.cs | 2 ++ 4 files changed, 43 insertions(+), 1 deletion(-) diff --git a/Assets/Fungus/Scripts/Editor/BlockEditor.cs b/Assets/Fungus/Scripts/Editor/BlockEditor.cs index 5850dfd6..e31d842f 100644 --- a/Assets/Fungus/Scripts/Editor/BlockEditor.cs +++ b/Assets/Fungus/Scripts/Editor/BlockEditor.cs @@ -19,6 +19,8 @@ namespace Fungus.EditorUtils { public static List actionList = new List(); + public static bool SelectedBlockDataStale { get; set; } + protected Texture2D upIcon; protected Texture2D downIcon; protected Texture2D addIcon; @@ -101,6 +103,8 @@ namespace Fungus.EditorUtils } + EditorGUI.BeginChangeCheck(); + if (block == flowchart.SelectedBlock) { // Custom tinting @@ -251,6 +255,12 @@ namespace Fungus.EditorUtils } } + + if (EditorGUI.EndChangeCheck()) + { + SelectedBlockDataStale = true; + } + serializedObject.ApplyModifiedProperties(); } @@ -364,7 +374,14 @@ namespace Fungus.EditorUtils EventHandlerEditor eventHandlerEditor = Editor.CreateEditor(block._EventHandler) as EventHandlerEditor; if (eventHandlerEditor != null) { + EditorGUI.BeginChangeCheck(); eventHandlerEditor.DrawInspectorGUI(); + + if(EditorGUI.EndChangeCheck()) + { + SelectedBlockDataStale = true; + } + DestroyImmediate(eventHandlerEditor); } } diff --git a/Assets/Fungus/Scripts/Editor/FlowchartEditor.cs b/Assets/Fungus/Scripts/Editor/FlowchartEditor.cs index ea17042f..f9566f21 100644 --- a/Assets/Fungus/Scripts/Editor/FlowchartEditor.cs +++ b/Assets/Fungus/Scripts/Editor/FlowchartEditor.cs @@ -27,7 +27,10 @@ namespace Fungus.EditorUtils protected Texture2D addTexture; protected VariableListAdaptor variableListAdaptor; - + + + public static bool FlowchartDataStale { get; set; } + protected virtual void OnEnable() { if (NullTargetCheck()) // Check for an orphaned editor instance @@ -58,6 +61,8 @@ namespace Fungus.EditorUtils flowchart.UpdateHideFlags(); + EditorGUI.BeginChangeCheck(); + EditorGUILayout.PropertyField(descriptionProp); EditorGUILayout.PropertyField(colorCommandsProp); EditorGUILayout.PropertyField(hideComponentsProp); @@ -73,6 +78,12 @@ namespace Fungus.EditorUtils //ReorderableListGUI.ListField(hideCommandsProp); EditorGUILayout.PropertyField(hideCommandsProp, new GUIContent(hideCommandsProp.displayName, hideCommandsProp.tooltip), true); + if(EditorGUI.EndChangeCheck()) + { + FlowchartDataStale = true; + } + + GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button(new GUIContent("Open Flowchart Window", "Opens the Flowchart Window"))) diff --git a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs index e4af217e..30f17c2d 100644 --- a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs +++ b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs @@ -301,6 +301,18 @@ namespace Fungus.EditorUtils CommandEditor.SelectedCommandDataStale = false; Repaint(); } + + if(BlockEditor.SelectedBlockDataStale) + { + BlockEditor.SelectedBlockDataStale = false; + Repaint(); + } + + if (FlowchartEditor.FlowchartDataStale) + { + FlowchartEditor.FlowchartDataStale = false; + Repaint(); + } } else { diff --git a/Assets/Fungus/Scripts/Editor/PopupContent/EventSelectorPopupWindowContent.cs b/Assets/Fungus/Scripts/Editor/PopupContent/EventSelectorPopupWindowContent.cs index b295f3a0..66c9c936 100644 --- a/Assets/Fungus/Scripts/Editor/PopupContent/EventSelectorPopupWindowContent.cs +++ b/Assets/Fungus/Scripts/Editor/PopupContent/EventSelectorPopupWindowContent.cs @@ -149,6 +149,8 @@ namespace Fungus.EditorUtils block._EventHandler = newHandler; } + BlockEditor.SelectedBlockDataStale = true; + // Because this is an async call, we need to force prefab instances to record changes PrefabUtility.RecordPrefabInstancePropertyModifications(block); }