void OnGUI() { if (follower == null) { return; } float maxWidth = 250f; //if the address depth is bigger than 1 (at least one junction is entered), offer an option to exit the last junction if (follower.address.depth > 1) { if (GUI.Button(new Rect(5, 10, 35, 20), "< X")) { follower.ExitAddress(1); GetAvailableJunctions(); } } for (int i = 0; i < nodes.Count; i++) { Node.Connection connection = nodes[i].GetConnections()[connectionIndices[i]]; GUI.Label(new Rect(0, 30 + 20 * i, maxWidth * 0.75f, 20), connection.computer.name + " [at P" + pointIndices[i] + "]"); float x = maxWidth - 70f; if (connection.pointIndex > 0) { if (GUI.Button(new Rect(x, 30 + 20 * i, 35, 20), "◄─")) { follower.EnterAddress(nodes[i], connectionIndices[i], Spline.Direction.Backward); GetAvailableJunctions(); break; } x += 35f; } if (connection.pointIndex < connection.computer.pointCount - 1) { if (GUI.Button(new Rect(x, 30 + 20 * i, 35, 20), "─►")) { follower.EnterAddress(nodes[i], connectionIndices[i], Spline.Direction.Forward); GetAvailableJunctions(); break; } } } }
void OnGUI() { if (user == null) { Close(); } Rect rect = new Rect(5, 5, position.width * 0.4f - 10, position.height - 10); GUI.Box(rect, "Current Address"); Rect viewRect = new Rect(0, 0, position.width * 0.4f - 25, user.address.depth * 20 + 20); scroll = GUI.BeginScrollView(rect, scroll, viewRect); GUI.color = new Color(1f, 1f, 1f, 0.5f); GUI.Label(new Rect(0, 30, viewRect.width * 0.75f, 20), user.address.root.name + " [" + user.address.elements[0].startPoint + " - " + user.address.elements[0].endPoint + "] "); GUI.color = Color.white; for (int i = 1; i < user.address.depth; i++) { string dirString = "─►"; if (user.address.elements[i].startPoint > user.address.elements[i].endPoint) { dirString = "◄─"; } GUI.Label(new Rect(0, 30 + 20 * i, viewRect.width - 35f, 20), user.address.elements[i].computer.name + " [" + user.address.elements[i].startPoint + " - " + user.address.elements[i].endPoint + "] " + dirString); if (GUI.Button(new Rect(viewRect.width - 30f, 30 + 20 * i, 30, 20), "x")) { user.ExitAddress(user.address.depth - i); GetAvailable(); SceneView.RepaintAll(); break; } } GUI.EndScrollView(); rect = new Rect(position.width * 0.4f, 5, position.width * 0.6f - 5, position.height - 10); GUI.Box(rect, "Available junctions"); viewRect = new Rect(0, 0, position.width * 0.6f - 20, nodes.Count * 20); scroll2 = GUI.BeginScrollView(rect, scroll2, viewRect); for (int i = 0; i < nodes.Count; i++) { Node.Connection connection = nodes[i].GetConnections()[connectionIndices[i]]; GUI.Label(new Rect(0, 30 + 20 * i, viewRect.width * 0.75f, viewRect.height), connection.computer.name + " [at P" + pointIndices[i] + "]"); float x = viewRect.width - 70f; if (connection.pointIndex > 0) { if (GUI.Button(new Rect(x, 30 + 20 * i, 35, 20), "◄─")) { user.EnterAddress(nodes[i], connectionIndices[i], Spline.Direction.Backward); GetAvailable(); SceneView.RepaintAll(); break; } x += 35f; } if (connection.pointIndex < connection.computer.pointCount - 1) { if (GUI.Button(new Rect(x, 30 + 20 * i, 35, 20), "─►")) { user.EnterAddress(nodes[i], connectionIndices[i], Spline.Direction.Forward); GetAvailable(); SceneView.RepaintAll(); break; } } } GUI.EndScrollView(); }