void DrawInputs(Node node, float x, float y, float nodeWidth, float nodeHeight) { float CellSize = Styles.CellSize; Rect inputRect = new Rect(x, y, nodeWidth, CellSize); Rect graphicRect = new Rect(node.Position.x + Styles.InputShift.x, y + Styles.InputShift.y, Styles.IOSize, Styles.IOSize); float interactionOffset = Mathf.Max(graphicRect.width, CellSize * 2); Rect interactionRect = new Rect(node.Position.x - interactionOffset, y, inputRect.width + interactionOffset, CellSize); Rect smallInputRect = new Rect(interactionRect.x, interactionRect.y, interactionOffset, CellSize); for (int i = 0; i < node.Inputs.Length; i++) { Link link = node.Inputs[i]; Node inNode = _nodeData.GetNode(link); GUI.Label(inputRect, link.Name); if (inNode is DefaultNode) { Rect defaultRect = inputRect; defaultRect.width = inNode.NodeWidth * CellSize; defaultRect.x -= defaultRect.width; GUI.color = Styles.GetColor(inNode.OutputType); Rect defaultBackRect = defaultRect; defaultBackRect.height += 1; GUI.Box(defaultBackRect, "", Styles.DefaultValue); GUI.color = Color.white; float savedLabelWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 8; string name = (inNode.OutputType == ValueType.Float || inNode.OutputType == ValueType.Int) ? " " : ""; DrawProperty(defaultRect, inNode, "Value", name); EditorGUIUtility.labelWidth = savedLabelWidth; defaultRect.xMax += inputRect.width; _linkDraging.ProcessNodeInput(node, i, defaultRect, smallInputRect); } else { GUIStyle gs = inNode != null ? Styles.GraphicPointActive : Styles.GraphicPoint; GUI.color = inNode != null?NodeEditorWindow.GetLinkColor(inNode, node) : Styles.GetColor(link.Type); GUI.Box(graphicRect, "", gs); GUI.color = Color.white; _linkDraging.ProcessNodeInput(node, i, interactionRect, smallInputRect); } //_linkDraging.ProcessNodeInput(node, i, interactionRect, smallInputRect); inputRect.y = y += inputRect.height; graphicRect.y = inputRect.y + Styles.InputShift.y; interactionRect.y = inputRect.y; smallInputRect.y = inputRect.y; } }
public LinkDraging(NodeEditorWindow window) { Window = window; }