diff options
| author | yum <yum.food.vr@gmail.com> | 2026-01-06 16:54:30 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2026-01-06 16:54:30 -0800 |
| commit | b1bfb0400c65b2602670bb22eea50a8b9db285a8 (patch) | |
| tree | 57c6fec8975fa8a0e7a4cbc0e8c6e0c4f730e5cb /Scripts | |
| parent | 8e860ac8c999fcf115329d6d480e38f6b1fee179 (diff) | |
Fold: fix save/restore logic
Diffstat (limited to 'Scripts')
| -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); |
