diff options
Diffstat (limited to 'Scripts/Fold/Editor/FoldWindow.cs')
| -rw-r--r-- | Scripts/Fold/Editor/FoldWindow.cs | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/Scripts/Fold/Editor/FoldWindow.cs b/Scripts/Fold/Editor/FoldWindow.cs deleted file mode 100644 index f0f9b42..0000000 --- a/Scripts/Fold/Editor/FoldWindow.cs +++ /dev/null @@ -1,85 +0,0 @@ -using UnityEditor; -using UnityEngine; -using UnityEngine.UIElements; - -public class FoldWindow : EditorWindow -{ - const string GraphPath = "Assets/FoldGraph.asset"; - - FoldGraphView graphView; - FoldGraph graphAsset; - - [MenuItem("Tools/yum_food/Fold")] - public static void Open() - { - 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.Dispose(); - graphView = null; - } - - AssetDatabase.SaveAssets(); - } - - 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); - if (asset == null) - { - asset = CreateInstance<FoldGraph>(); - AssetDatabase.CreateAsset(asset, GraphPath); - AssetDatabase.SaveAssets(); - } - - return asset; - } - - void ConstructGraphView() - { - graphView = new FoldGraphView(this, graphAsset) - { - name = "Fold 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) - { - if (string.IsNullOrEmpty(message)) - return; - - ShowNotification(new GUIContent(message)); - } -} |
