public void Draw() { NodeData node = NodeGUIUtility.GetInstance <NodeData>(data.nodeGUID); data.rect.y = node.rect.y + 15f - data.rect.height * 0.5f + 40f * data.index; switch (data.pointType) { case ConnectionPointType.In: case ConnectionPointType.Parameter: data.rect.x = node.rect.x - data.rect.width + 8f; if (GUI.Button(data.rect, NodeGUIResources.dot)) { NodeBaseEditor.Current.OnClickPoint(this); } break; case ConnectionPointType.Out: case ConnectionPointType.Return: data.rect.x = node.rect.x + node.rect.width - 8f; if (GUI.Button(data.rect, NodeGUIResources.dotOuter)) { NodeBaseEditor.Current.OnClickPoint(this); } break; } }
private void LoadData() { AllClear(); NodeSerializableData datas = owner.Load(); if (datas == null || datas.nodeDatas == null) { return; } foreach (var node in datas.nodeDatas) { NodeGUIUtility.AddInstance(node); CreateNodeInLoad(node); } foreach (var node in datas.nodeFuncDatas) { NodeGUIUtility.AddInstance(node); CreateNodeInLoad(node); } foreach (var point in datas.nodePointDatas) { NodeGUIUtility.AddInstance(point); CreateNodePointInLoad(point); } foreach (var connect in datas.nodeConnectionDatas) { NodeGUIUtility.AddInstance(connect); CreateConnectionInLoad(connect); } }
public void OnClickRemoveNode(NodeGUI node) { if (connections != null) { List <Connection> connectionsToRemove = new List <Connection>(); for (int i = 0; i < connections.Count; i++) { if (node.data.points.Contains(connections[i].data.inGUID) || node.data.points.Contains(connections[i].data.outGUID)) { connectionsToRemove.Add(connections[i]); } } for (int i = 0; i < connectionsToRemove.Count; i++) { OnClickRemoveConnection(connectionsToRemove[i]); } connectionsToRemove = null; } nodes.Remove(node); node.RemovePoints(); NodeGUIUtility.RemoveInstance(node.data); }
public void Draw() { GUILayout.BeginArea(data.rect); if (isSelected) { GUILayout.BeginVertical(NodeGUIResources.styles.highlightNode); } else { GUILayout.BeginVertical(NodeGUIResources.styles.node); } GUILayout.Label(data.methodName, NodeGUIResources.styles.nodeHeader, GUILayout.Height(20)); GUILayout.Label(data.returnType, NodeGUIResources.styles.nodeHeader, GUILayout.Height(20)); List <ConnectionPoint> inPoints = points.FindAll((p) => (int)p.data.pointType < 2); foreach (var point in inPoints) { point.data.cachedValue = NodeGUIUtility.Draw(point.data); } GUILayout.Label("", NodeGUIResources.styles.nodeHeader, GUILayout.Height(20)); GUILayout.EndVertical(); GUILayout.EndArea(); if (points != null) { for (int i = 0; i < points.Count; i++) { points[i].Draw(); } } }
public void RemovePoints() { foreach (var p in points) { NodeGUIUtility.RemoveInstance(p.data); } points.Clear(); }
public void OnClickRemoveConnection(Connection connection) { connections.Remove(connection); NodePointData inP = NodeGUIUtility.GetInstance <NodePointData>(connection.data.inGUID), outP = NodeGUIUtility.GetInstance <NodePointData>(connection.data.outGUID); inP.connections.Remove(connection.data.GUID); outP.connections.Remove(connection.data.GUID); NodeGUIUtility.RemoveInstance(connection.data); }
public static Connection CreateConnectionInRuntime(NodeConnectionData data) { Connection c = new Connection(data); NodePointData inP = NodeGUIUtility.GetInstance <NodePointData>(data.inGUID) , outP = NodeGUIUtility.GetInstance <NodePointData>(data.outGUID); inP.connections.Add(data.GUID); outP.connections.Add(data.GUID); return(c); }
public NodePointData(int index, string nodeGUID, ConnectionPointType pointType, string parameterType, string parameterName) : base() { this.index = index; this.nodeGUID = nodeGUID; this.pointType = pointType; this.parameterType = parameterType; this.parameterName = parameterName; //unityengine.vector3 어셈블리 이름 타입에 적어줘야함 this.cachedValue = NodeGUIUtility.GetDefaultValue(NodeGUIUtility.GetType(parameterType))?.ToString() ?? "null"; }
public void Draw() { NodePointData inP = NodeGUIUtility.GetInstance <NodePointData>(data.inGUID), outP = NodeGUIUtility.GetInstance <NodePointData>(data.outGUID); Handles.DrawBezier( inP.rect.center, outP.rect.center, inP.rect.center + Vector2.left * 50f, outP.rect.center - Vector2.left * 50f, Color.white, null, 4f ); if (Handles.Button((inP.rect.center + outP.rect.center) * 0.5f, Quaternion.identity, 4, 8, Handles.RectangleHandleCap)) { NodeBaseEditor.Current.OnClickRemoveConnection(this); } }
public ConnectionPoint(NodePointData data) { NodeGUIUtility.AddInstance(data); this.data = data; }
public NodeGUI(NodeData data) { NodeGUIUtility.AddInstance(data); this.data = data; data.rect.size = new Vector2(180f, 4000f); }
public void MakePoints() { if (this.data is NodeFuncData) { NodeFuncData data = this.data as NodeFuncData; List <Type> methodParameters = new List <Type>(); foreach (var point in data.parameters) { methodParameters.Add(NodeGUIUtility.GetType(point)); } if (data.nodeType == NodeType.Constructor) { ConstructorInfo method = NodeGUIUtility.GetType(data.funcClassType).GetConstructor(methodParameters.ToArray()); ParameterInfo[] parameters = method.GetParameters(); AddPoint(new NodePointData(1, data.GUID, ConnectionPointType.Return, data.funcClassType, "instance")); int index = 1; foreach (var parameter in parameters) { AddPoint(new NodePointData(index++, data.GUID, ConnectionPointType.Parameter, parameter.ParameterType.FullName, parameter.Name)); } } else { Type classType = NodeGUIUtility.GetType(data.funcClassType); MethodInfo method = classType.GetMethod(data.methodName, methodParameters.ToArray()); ParameterInfo[] parameters = method.GetParameters(); int index = 1; if (method.ReturnParameter.ParameterType == typeof(void)) { AddPoint(new NodePointData(0, data.GUID, ConnectionPointType.In, typeof(void).FullName, "Logic", null)); AddPoint(new NodePointData(0, data.GUID, ConnectionPointType.Out, typeof(void).FullName, "Logic", null)); data.nodeType = NodeType.Logic; } else { AddPoint(new NodePointData(1, data.GUID, ConnectionPointType.Return, method.ReturnParameter.ParameterType.FullName, method.ReturnParameter.Name)); data.nodeType = NodeType.Func; } if (!method.IsStatic) { AddPoint(new NodePointData(index++, data.GUID, ConnectionPointType.Parameter, data.funcClassType, "This")); } foreach (var parameter in parameters) { AddPoint(new NodePointData(index++, data.GUID, ConnectionPointType.Parameter, parameter.ParameterType.FullName, parameter.Name)); } if (data.methodName.Contains("get_") || data.methodName.Contains("set_")) { data.nodeType = NodeType.Property; } } } else { if (data.nodeType == NodeType.Condition) { AddPoint(new NodePointData(0, data.GUID, ConnectionPointType.In, typeof(void).FullName, "Logic", null)); AddPoint(new NodePointData(1, data.GUID, ConnectionPointType.Parameter, typeof(bool).FullName, "Condition")); AddPoint(new NodePointData(0, data.GUID, ConnectionPointType.Out, typeof(void).FullName, "Logic", null)); AddPoint(new NodePointData(1, data.GUID, ConnectionPointType.Out, typeof(void).FullName, "Logic", null)); } else if (data.nodeType == NodeType.For) { AddPoint(new NodePointData(0, data.GUID, ConnectionPointType.In, typeof(void).FullName, "Logic", null)); AddPoint(new NodePointData(1, data.GUID, ConnectionPointType.Parameter, typeof(int).FullName, "LoofCount")); AddPoint(new NodePointData(0, data.GUID, ConnectionPointType.Out, typeof(void).FullName, "Logic", null)); AddPoint(new NodePointData(1, data.GUID, ConnectionPointType.Out, typeof(void).FullName, "Logic", null)); } else if (data.nodeType == NodeType.Event) { AddPoint(new NodePointData(0, data.GUID, ConnectionPointType.Out, typeof(void).FullName, "Logic", null)); AddPoint(new NodePointData(1, data.GUID, ConnectionPointType.Return, typeof(Character).FullName, "Owner", null)); } else if (data.nodeType == NodeType.TimeLine) { AddPoint(new NodePointData(0, data.GUID, ConnectionPointType.Out, typeof(void).FullName, "Logic", null)); AddPoint(new NodePointData(1, data.GUID, ConnectionPointType.Return, typeof(Character).FullName, "Owner", null)); AddPoint(new NodePointData(1, data.GUID, ConnectionPointType.Parameter, typeof(float).FullName, "Time")); } } }
public Connection(NodeConnectionData data) { NodeGUIUtility.AddInstance(data); this.data = data; }