summaryrefslogtreecommitdiffstats
path: root/Scripts/Fold/Editor/FoldWindow.cs
blob: 270bc2aa1a350871a6eb92d1365e172c8a035175 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using UnityEngine;
using UnityEditor;
using GraphProcessor;

public class FoldWindow : BaseGraphWindow
{
    const string GraphPath = "Assets/FoldGraph.asset";

    [MenuItem("Tools/yum_food/Fold")]
    public static void Open()
    {
        var graph = AssetDatabase.LoadAssetAtPath<FoldGraph>(GraphPath);
        if (graph == null)
        {
            graph = ScriptableObject.CreateInstance<FoldGraph>();
            AssetDatabase.CreateAsset(graph, GraphPath);
            AssetDatabase.SaveAssets();
        }

        var w = GetWindow<FoldWindow>();
        w.InitializeGraph(graph);
        w.Show();
    }

    protected override void OnDestroy() => graphView?.Dispose();

    protected override void InitializeWindow(BaseGraph graph)
    {
        titleContent = new GUIContent("Fold");
        if (graphView == null) rootView.Add(graphView = new FoldGraphView(this));
    }
}