summaryrefslogtreecommitdiffstats
path: root/Scripts/Fold/Editor/FoldWindow.cs
blob: 0203db1845d8650af24d13f4aaec7c78d49296cf (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
33
34
35
36
37
38
39
using UnityEngine;
using UnityEditor;
using GraphProcessor;

public class FoldWindow : BaseGraphWindow
{
    BaseGraph tmpGraph;

    [MenuItem("Tools/yum_food/Fold")]
    public static BaseGraphWindow Open()
    {
        var graphWindow = CreateWindow<FoldWindow>();

        graphWindow.tmpGraph = ScriptableObject.CreateInstance<BaseGraph>();
        graphWindow.tmpGraph.hideFlags = HideFlags.HideAndDontSave;
        graphWindow.InitializeGraph(graphWindow.tmpGraph);

        graphWindow.Show();
        return graphWindow;
    }

    protected override void OnDestroy()
    {
        graphView?.Dispose();
        DestroyImmediate(tmpGraph);
    }

    protected override void InitializeWindow(BaseGraph graph)
    {
        titleContent = new GUIContent("Fold");

        // Create the graph view with our custom view
        if (graphView == null)
            graphView = new FoldGraphView(this);

        rootView.Add(graphView);
    }
}