void DrawDummyLayout(FunctionGraphEditorNodeLayout info) { EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); Rect r = EditorGUILayout.GetControlRect(); r.size = new Vector2(25, 25); GUI.Box(r, "", info.Style); if (info.InConnectionPointsInfo != null) { for (int i = 0; i < info.InConnectionPointCount; i++) { info.Draw(r, info.InConnectionPointsInfo[i]); } } if (info.OutConnectionPointsInfo != null) { for (int i = 0; i < info.OutConnectionPointCount; i++) { info.Draw(r, info.OutConnectionPointsInfo[i]); } } EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); }
public virtual void CreateNodeDrawableInfo(Vector2 creationPosition, FunctionGraphEditorNodeLayout layout) { //one out conn point Rect = new Rect(creationPosition, new Vector2(layout.Width, layout.Height)); style = layout.Style; //create connection points CreateConnectionPoints(layout); }
private void CreateConnectionPoints(float width, float height, FunctionGraphEditorNodeLayout layout, FunctionGraphEditorNodeLayout.ListType list, Action <ConnectionPoint, int> onClick) { int count = (list == 0) ? layout.InConnectionPointCount : layout.OutConnectionPointCount; string label = ""; //loop over all set create type and set offset rect correctly for (int i = 0; i < count; i++) { if (list == FunctionGraphEditorNodeLayout.ListType.In) { if (GraphNode is ParentableNode) { label = (GraphNode as ParentableNode).GetChildLabelByIdx(i); } else { label = ""; } } FunctionGraphEditorNodeLayout.ConnectionPointInfo info = layout[list, i]; //figure out width and height Vector2 size = new Vector2(width * info.Width, height * info.Height); //figure out offset Vector2 offset = new Vector2(width, height); offset.Scale(new Vector2(info.UVx, info.UVy)); offset -= size * .5f; connectionPoints.Add( new ConnectionPoint( info.Type, i, this, new Rect(offset, size), info.Style, onClick, label )); } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); FunctionGraphEditorNodeLayout tar = target as FunctionGraphEditorNodeLayout; EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); Rect r = EditorGUILayout.GetControlRect(); r.size = new Vector2(tar.Width, tar.Height); //r.size = new Vector2(150f, 150f); GUI.Box(r, "", tar.Style); if (tar.InConnectionPointsInfo != null) { for (int i = 0; i < tar.InConnectionPointCount; i++) { tar.Draw(r, tar.InConnectionPointsInfo[i], i); } } if (tar.OutConnectionPointsInfo != null) { for (int i = 0; i < tar.OutConnectionPointCount; i++) { tar.Draw(r, tar.OutConnectionPointsInfo[i], i); } } for (int i = 0; i < tar.Height / 5f; i++) { EditorGUILayout.Space(); } }
public FunctionGraphEditorNode(Vector2 creationPosition, BaseFuncGraphNode node, FunctionGraphEditor editor, FunctionGraphEditorNodeLayout layout) { editorBelongingTo = editor; GraphNode = node; connectionPoints = new List <ConnectionPoint>(); CreateNodeDrawableInfo(creationPosition, layout); }
private void CreateConnectionPoints(FunctionGraphEditorNodeLayout layout) { CreateConnectionPoints(layout.Width, layout.Height, layout, FunctionGraphEditorNodeLayout.ListType.Out, OnOutConnectionPointClick); CreateConnectionPoints(layout.Width, layout.Height, layout, FunctionGraphEditorNodeLayout.ListType.In, OnInConnectionPointClick); }
public static FunctionGraphEditorNode CreateEditorNode(Vector2 pos, BaseFuncGraphNode n, FunctionGraphEditor editor, FunctionGraphEditorNodeLayout layout) { var attr = n.GetType().GetCustomAttributes(typeof(EditorNodeTypeAttribute), true) as EditorNodeTypeAttribute[]; EditorNodeTypeAttribute.NodeType type = EditorNodeTypeAttribute.NodeType.Default; if (attr.Length > 0) { type = attr[0].Type; } switch (type) { case EditorNodeTypeAttribute.NodeType.Default: return(new FunctionGraphEditorNode(pos, n, editor, layout)); case EditorNodeTypeAttribute.NodeType.FloatField: return(new FunctionGraphEditorNodeConstant(pos, n, editor, layout)); case EditorNodeTypeAttribute.NodeType.Variable: return(new FunctionGraphEditorNodeVariable(pos, n, editor, layout)); default: return(new FunctionGraphEditorNode(pos, n, editor, layout)); } }
public void SetTypeAndLayout(Type t, FunctionGraphEditorNodeLayout layout) { _Type = t; type = t.ToString(); Layout = layout; }
public FunctionGraphEditorNodeVariable(Vector2 creationPosition, BaseFuncGraphNode node, FunctionGraphEditor editor, FunctionGraphEditorNodeLayout layout) : base(creationPosition, node, editor, layout) { n = node as VariableNode; }
public FunctionGraphEditorNodeConstant(Vector2 creationPosition, BaseFuncGraphNode node, FunctionGraphEditor editor, FunctionGraphEditorNodeLayout layout) : base(creationPosition, node, editor, layout) { n = node as ConstantNode; }