diff options
| author | yum <yum.food.vr@gmail.com> | 2026-01-06 16:30:28 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2026-01-06 16:30:28 -0800 |
| commit | 1a4daf3fa6e6a7178fe42bcaa247ce434baf6881 (patch) | |
| tree | 8493a04bee4c53eda492ce0e6cd5c194d7f9e393 /Scripts/Fold/Editor/FoldWindow.cs | |
| parent | 9b45bce6d4ca528cf5bbc78aeaa0b6b06e0f1a29 (diff) | |
Fold: drop NodeGraphProcessor
Diffstat (limited to 'Scripts/Fold/Editor/FoldWindow.cs')
| -rw-r--r-- | Scripts/Fold/Editor/FoldWindow.cs | 68 |
1 files changed, 53 insertions, 15 deletions
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<FoldGraph>(GraphPath); - if (graph == null) + var window = GetWindow<FoldWindow>(); + 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<FoldGraph>(GraphPath); + if (asset == null) { - graph = ScriptableObject.CreateInstance<FoldGraph>(); - AssetDatabase.CreateAsset(graph, GraphPath); + asset = CreateInstance<FoldGraph>(); + AssetDatabase.CreateAsset(asset, GraphPath); AssetDatabase.SaveAssets(); } - var w = GetWindow<FoldWindow>(); - 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 +} |
