From 1a4daf3fa6e6a7178fe42bcaa247ce434baf6881 Mon Sep 17 00:00:00 2001 From: yum Date: Tue, 6 Jan 2026 16:30:28 -0800 Subject: Fold: drop NodeGraphProcessor --- Scripts/Fold/Editor/FoldWindow.cs | 68 ++++++++++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 15 deletions(-) (limited to 'Scripts/Fold/Editor/FoldWindow.cs') diff --git a/Scripts/Fold/Editor/FoldWindow.cs b/Scripts/Fold/Editor/FoldWindow.cs index 270bc2a..44e373b 100644 --- a/Scripts/Fold/Editor/FoldWindow.cs +++ b/Scripts/Fold/Editor/FoldWindow.cs @@ -1,32 +1,70 @@ -using UnityEngine; using UnityEditor; -using GraphProcessor; +using UnityEngine; +using UnityEngine.UIElements; -public class FoldWindow : BaseGraphWindow +public class FoldWindow : EditorWindow { const string GraphPath = "Assets/FoldGraph.asset"; + FoldGraphView graphView; + FoldGraph graphAsset; + [MenuItem("Tools/yum_food/Fold")] public static void Open() { - var graph = AssetDatabase.LoadAssetAtPath(GraphPath); - if (graph == null) + var window = GetWindow(); + window.titleContent = new GUIContent("Fold"); + window.Show(); + } + + void OnEnable() + { + graphAsset = LoadOrCreateGraph(); + ConstructGraphView(); + } + + void OnDisable() + { + if (graphView != null) + { + rootVisualElement.Remove(graphView); + graphView = null; + } + + AssetDatabase.SaveAssets(); + } + + FoldGraph LoadOrCreateGraph() + { + var asset = AssetDatabase.LoadAssetAtPath(GraphPath); + if (asset == null) { - graph = ScriptableObject.CreateInstance(); - AssetDatabase.CreateAsset(graph, GraphPath); + asset = CreateInstance(); + AssetDatabase.CreateAsset(asset, GraphPath); AssetDatabase.SaveAssets(); } - var w = GetWindow(); - w.InitializeGraph(graph); - w.Show(); + return asset; } - protected override void OnDestroy() => graphView?.Dispose(); + void ConstructGraphView() + { + graphView = new FoldGraphView(this, graphAsset) + { + name = "Fold Graph" + }; - protected override void InitializeWindow(BaseGraph graph) + graphView.style.flexGrow = 1f; + graphView.style.width = Length.Percent(100); + graphView.style.height = Length.Percent(100); + rootVisualElement.Add(graphView); + } + + public void ShowNotification(string message) { - titleContent = new GUIContent("Fold"); - if (graphView == null) rootView.Add(graphView = new FoldGraphView(this)); + if (string.IsNullOrEmpty(message)) + return; + + ShowNotification(new GUIContent(message)); } -} \ No newline at end of file +} -- cgit v1.2.3