diff options
Diffstat (limited to 'Scripts/Fold')
| -rw-r--r-- | Scripts/Fold/Editor/FoldGraphView.cs | 1 | ||||
| -rw-r--r-- | Scripts/Fold/Editor/FoldWindow.cs | 14 |
2 files changed, 15 insertions, 0 deletions
diff --git a/Scripts/Fold/Editor/FoldGraphView.cs b/Scripts/Fold/Editor/FoldGraphView.cs index d4a91dc..6602af3 100644 --- a/Scripts/Fold/Editor/FoldGraphView.cs +++ b/Scripts/Fold/Editor/FoldGraphView.cs @@ -640,6 +640,7 @@ public class FoldGraphView : GraphView public void MarkDirty() { EditorUtility.SetDirty(graphAsset); + AssetDatabase.SaveAssets(); } public void ShowNodeCreationMenuFromPort(Port startPort, Vector2 worldPosition) => ShowSearchWindow(startPort, worldPosition); diff --git a/Scripts/Fold/Editor/FoldWindow.cs b/Scripts/Fold/Editor/FoldWindow.cs index 814225c..3ba556c 100644 --- a/Scripts/Fold/Editor/FoldWindow.cs +++ b/Scripts/Fold/Editor/FoldWindow.cs @@ -37,6 +37,20 @@ public class FoldWindow : EditorWindow Undo.undoRedoPerformed -= OnUndoRedo; } + void OnFocus() + { + // If we lost the graph view for any reason, rebuild it. Otherwise, reload to match the asset on disk. + if (graphView == null) + { + graphAsset = LoadOrCreateGraph(); + ConstructGraphView(); + } + else + { + graphView.Reload(); + } + } + FoldGraph LoadOrCreateGraph() { var asset = AssetDatabase.LoadAssetAtPath<FoldGraph>(GraphPath); |
