public override void OnInspectorGUI() { base.OnInspectorGUI(); Node node = (Node)target; if (nodes.Length == 1) { if (addComp != null) { string[] pointNames = new string[availablePoints.Length]; for (int i = 0; i < pointNames.Length; i++) { pointNames[i] = "Point " + (availablePoints[i] + 1); } if (availablePoints.Length > 0) { addPoint = EditorGUILayout.Popup("Link point", addPoint, pointNames); } else { EditorGUILayout.LabelField("No Points Available"); } if (GUILayout.Button("Cancel")) { addComp = null; addPoint = 0; } if (addPoint >= 0 && availablePoints.Length > addPoint) { if (node.HasConnection(addComp, availablePoints[addPoint])) { EditorGUILayout.HelpBox("Connection already exists (" + addComp.name + "," + availablePoints[addPoint], MessageType.Error); } else if (GUILayout.Button("Link")) { AddConnection(addComp, availablePoints[addPoint]); } } } else { SplineEditorGUI.BeginContainerBox(ref connectionsOpen, "Connections"); if (connectionsOpen) { ConnectionsGUI(); } SplineEditorGUI.EndContainerBox(); Rect rect = GUILayoutUtility.GetLastRect(); SplineComputer[] addComps; SplineComputer lastComp = addComp; bool dragged = DreamteckEditorGUI.DropArea <SplineComputer>(rect, out addComps); if (dragged && addComps.Length > 0) { SelectComputer(addComps[0]); } if (lastComp != addComp) { SceneView.RepaintAll(); } } } else { EditorGUILayout.HelpBox("Connection UI not available when multiple Nodes are selected.", MessageType.Info); } SplineEditorGUI.BeginContainerBox(ref settingsOpen, "Settings"); if (settingsOpen) { SettingsGUI(); } SplineEditorGUI.EndContainerBox(); }
void RenderConnections() { Node node = (Node)target; Node.Connection[] connections = node.GetConnections(); scroll = EditorGUILayout.BeginScrollView(scroll, GUI.skin.box, GUILayout.Width(EditorGUIUtility.currentViewWidth - 30), GUILayout.Height(Mathf.Min(75 + connections.Length * 20, 200))); EditorGUILayout.LabelField("Connections"); EditorGUILayout.Space(); if (connections.Length > 0) { for (int i = 0; i < connections.Length; i++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(connections[i].computer.name + " at point " + (connections[i].pointIndex + 1)); if (GUILayout.Button("Select", GUILayout.Width(70))) { Selection.activeGameObject = connections[i].computer.gameObject; } if (SplineEditorGUI.EditorLayoutSelectableButton(new GUIContent("Swap Tangents"), connections[i].computer.type == Spline.Type.Bezier, connections[i].invertTangents)) { connections[i].invertTangents = !connections[i].invertTangents; node.UpdateConnectedComputers(); SceneView.RepaintAll(); } if (GUILayout.Button("x", GUILayout.Width(20))) { Undo.RecordObject(node, "Remove connection"); Undo.RecordObject(connections[i].computer, "Remove node"); node.RemoveConnection(connections[i].computer, connections[i].pointIndex); } EditorGUILayout.EndHorizontal(); } } else { EditorGUILayout.HelpBox("Drag & Drop SplineComputers here to link their points.", MessageType.Info); } EditorGUILayout.EndScrollView(); Rect rect = GUILayoutUtility.GetLastRect(); SplineComputer[] addComps; SplineComputer lastComp = addComp; bool dragged = DreamteckEditorGUI.DropArea <SplineComputer>(rect, out addComps); if (dragged && addComps.Length > 0) { SelectComputer(addComps[0]); } if (lastComp != addComp) { SceneView.RepaintAll(); } node.transformNormals = EditorGUILayout.Toggle("Transform Normals", node.transformNormals); node.transformSize = EditorGUILayout.Toggle("Transform Size", node.transformSize); node.transformTangents = EditorGUILayout.Toggle("Transform Tangents", node.transformTangents); EditorGUI.BeginChangeCheck(); if (connections.Length > 1) { node.type = (Node.Type)EditorGUILayout.EnumPopup("Node type", node.type); } if (EditorGUI.EndChangeCheck()) { SceneView.RepaintAll(); node.UpdateConnectedComputers(); } }