This repository has been archived by the owner on Jan 29, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConnectionPoint.cs
45 lines (39 loc) · 1.51 KB
/
ConnectionPoint.cs
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
40
41
42
43
44
45
using UnityEngine;
public enum ConnectionPointType { In, Out }
public class ConnectionPoint
{
public Rect rect;
public ConnectionPointType type;
public DialogNode dialogNode;
public OptionNode optionNode;
public GUIStyle style;
public System.Action<ConnectionPoint> OnClickConnectionPoint;
public ConnectionPoint(DialogNode dialogNode, ConnectionPointType type, GUIStyle style, System.Action<ConnectionPoint> OnClickConnectionPoint)
{
this.dialogNode = dialogNode;
this.type = type;
this.style = style;
this.OnClickConnectionPoint = OnClickConnectionPoint;
rect = new Rect(0, 0, 10f, 20f);
}
public ConnectionPoint(OptionNode optionNode, ConnectionPointType type, GUIStyle style, System.Action<ConnectionPoint> OnClickConnectionPoint)
{
this.optionNode = optionNode;
this.type = type;
this.style = style;
this.OnClickConnectionPoint = OnClickConnectionPoint;
rect = new Rect(0, 0, 10f, 20f);
}
public void Draw()
{
rect.y = (type == ConnectionPointType.In) ? dialogNode.rect.y + (dialogNode.rect.height * 0.5f) : optionNode.rect.y + (optionNode.rect.height * 0.5f);
rect.x = (type == ConnectionPointType.In) ? dialogNode.rect.x - rect.width + 8f : optionNode.rect.x + optionNode.rect.width - 8f;
if (GUI.Button(rect, "", style))
{
if (OnClickConnectionPoint != null)
{
OnClickConnectionPoint(this);
}
}
}
}