summaryrefslogtreecommitdiff
path: root/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Nodes/OperatorNodes/CurveNode.cs
blob: 7babc539da43596b37d5b50ae7de0edbfffb039b (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 UNEB;

public class CurveNode : Node
{
    private AnimationCurve _curve = new AnimationCurve();
    private readonly Rect kCurveRange = new Rect(-1, -1, 2, 2);

    private const float kBodyHeight = 100f;

    public override void Init()
    {
        var input = AddInput();
        input.name = "Input";

        var output = AddOutput();
        output.name = "Output";

        FitKnobs();

        bodyRect.height += kBodyHeight;
        bodyRect.width = 150f;
    }

    public override void OnBodyGUI()
    {
        float boxHeight = kBodyHeight - kHeaderHeight;
        _curve = EditorGUILayout.CurveField(_curve, Color.cyan, kCurveRange, GUILayout.Height(boxHeight), GUILayout.ExpandWidth(true));
    }
}