private void DrawTodoItem(TodoItem item) { CustomGUIUtils.BeginGroup(); { switch (item.status) { case Status.PENDING: statusStyle = lightRed; break; case Status.IN_PROGRESS: statusStyle = lightYellow; break; case Status.DONE: statusStyle = lightGreen; break; default: statusStyle = GUIStyle.none; break; } EditorGUILayout.BeginHorizontal(statusStyle); EditorGUILayout.LabelField("" + item.name, GUILayout.Width(80f)); EditorGUILayout.EndHorizontal(); foreach (string todo in item.childTodos) { CustomGUIUtils.BeginGroup(); DrawTodoItem(item.childDict[todo]); CustomGUIUtils.EndGroup(); } } CustomGUIUtils.EndGroup(); }
public override void OnInspectorGUI() { if (GUILayout.Button("Delete Edge")) { //Node oldFromNode = edgeBehaviour.Edge.From; //Node oldToNode = edgeBehaviour.Edge.To; edgeBehaviour.Delete(); //oldFromNode.OnNodeChanged(); //oldToNode.OnNodeChanged(); } EditorGUILayout.Separator(); EditorGUILayout.Separator(); if (advancedGizmoSettings = EditorGUILayout.Foldout(advancedGizmoSettings, "Edge-Advanced-Gizmo-Settings")) { CustomGUIUtils.BeginGroup(); Edge_Behaviour.NodeGizmoSize = (Edge_Behaviour.GizmoSize)EditorGUILayout.EnumPopup("GizmoSize", Edge_Behaviour.NodeGizmoSize); Edge_Behaviour.DrawLabel = EditorGUILayout.Toggle("Show Label", Edge_Behaviour.DrawLabel); Edge_Behaviour.DrawLength = EditorGUILayout.Toggle("Show Length", Edge_Behaviour.DrawLength); CustomGUIUtils.EndGroup(); } EditorGUILayout.Separator(); EditorGUILayout.Separator(); // Draw the DefaultInspector for this Behvaiour showDefaultInspector = this.DrawDefaultInspectorFoldout(edgeBehaviour, showDefaultInspector); if (GUI.changed) { EditorUtility.SetDirty(edgeBehaviour); } }
public static bool DrawDefaultInspectorFoldout(this Editor customEditor, MonoBehaviour behaviour, bool showDefaultInspector) { // Globaly turned the DefaultInspectorFoldout on or off if (hideDefaultInspectorFoldout) { return(false); } if (showDefaultInspector = EditorGUILayout.Foldout(showDefaultInspector, behaviour.GetType().ToString() + "-Default-Inspector") && behaviour != null) { CustomGUIUtils.BeginGroup(); customEditor.DrawDefaultInspector(); CustomGUIUtils.EndGroup(); } return(showDefaultInspector); }
public override void OnInspectorGUI() { if (GUILayout.Button("Create Node")) { graphBehaviour.CreateNodeBehaviour(Vector3.zero); } //if (nodesFoldout = EditorGUILayout.Foldout(nodesFoldout, "Nodes (" + graph.Nodes.Count + ")")) //{ // CustomGUIUtils.BeginGroup(); // int count = 1; // foreach (Node node in graph.Nodes) // { // EditorGUILayout.LabelField("Node " + count++, node.Id); // //EditorGUILayout.ObjectField(edgeBeh, typeof(Behaviour_Edge2D), GUILayout.ExpandWidth(true)); // } // CustomGUIUtils.EndGroup(); //} //if (edgesFoldout = EditorGUILayout.Foldout(edgesFoldout, "Edges (" + graph.Edges.Count + ")")) //{ // CustomGUIUtils.BeginGroup(); // int count = 1; // foreach (Edge edge in graph.Edges) // { // EditorGUILayout.LabelField("Edge " + count++, edge.Id); // //EditorGUILayout.ObjectField(edgeBeh, typeof(Behaviour_Edge2D), GUILayout.ExpandWidth(true)); // } // CustomGUIUtils.EndGroup(); //} if (nodesFoldout = EditorGUILayout.Foldout(nodesFoldout, "Node Behaviours (" + graphBehaviour.NodeBehaviours.Count + ")")) { CustomGUIUtils.BeginGroup(); int count = 1; foreach (Node_Behaviour nodeBehaviour in graphBehaviour.NodeBehaviours) { EditorGUILayout.LabelField("NodeBehaviour " + count++, nodeBehaviour.Node.Id); //EditorGUILayout.ObjectField(edgeBeh, typeof(Behaviour_Edge2D), GUILayout.ExpandWidth(true)); } CustomGUIUtils.EndGroup(); } if (edgesFoldout = EditorGUILayout.Foldout(edgesFoldout, "Edge Behaviours (" + graphBehaviour.EdgeBehaviours.Count + ")")) { CustomGUIUtils.BeginGroup(); int count = 1; foreach (Edge_Behaviour edgeBehaviour in graphBehaviour.EdgeBehaviours) { EditorGUILayout.LabelField("EdgeBehaviour " + count++, edgeBehaviour.Edge.Id); //EditorGUILayout.ObjectField(edgeBeh, typeof(Behaviour_Edge2D), GUILayout.ExpandWidth(true)); } CustomGUIUtils.EndGroup(); } EditorGUILayout.Separator(); EditorGUILayout.Separator(); // Draw the DefaultInspector for this Behvaiour showDefaultInspector = this.DrawDefaultInspectorFoldout(graphBehaviour, showDefaultInspector); if (GUI.changed) { EditorUtility.SetDirty(graphBehaviour); } }
public override void OnInspectorGUI() { // Update client serializedObject.Update(); this.client.ServerMode = EditorGUILayout.Toggle("Act as Server", this.client.ServerMode); // Generate the connection dropdown options/content #region Dropdown connections var connectionNames = AmqpConfigurationEditor.GetConnectionNames(); var options = new List <GUIContent>(); for (var i = 0; i < connectionNames.Length; i++) { var cName = connectionNames[i]; if (string.IsNullOrEmpty(client.Connection) || client.Connection == cName) { index = i; } options.Add(new GUIContent(cName)); } // Connections drop down string tooltip = "Select the AMQP connection to use. Connections can be configured in the AMQP/Configuration menu."; index = EditorGUILayout.Popup(new GUIContent("Connection", tooltip), index, options.ToArray()); // If the index has changed, record the change if (index != lastIndex) { Undo.RecordObject(target, "Undo Connection change"); } // Set the connection name based on dropdown value client.Connection = connection.stringValue = options[index].text; #endregion // Dropdown connections // Draw the rest of the inspector's default layout //DrawDefaultInspector(); if (GUILayout.Button("Awake")) { this.client.Awake(); this.Repaint(); } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("EnableUpdate")) { this.client.EnableUpdate(); this.Repaint(); } if (GUILayout.Button("DisableUpdate")) { this.client.DisableUpdate(); this.Repaint(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Toggle("IsConnecting?", this.client.isConnecting); EditorGUILayout.Toggle("IsConnected?", this.client.IsConnected); EditorGUILayout.Toggle("hasConnected?", this.client.hasConnected); EditorGUILayout.Toggle("isDisconnecting?", this.client.isDisconnecting); EditorGUILayout.Toggle("hasDisconnected?", this.client.hasDisconnected); EditorGUILayout.Toggle("isReconnecting?", this.client.isReconnecting); EditorGUILayout.Toggle("wasBlocked?", this.client.wasBlocked); EditorGUILayout.Toggle("hasAborted?", this.client.hasAborted); EditorGUILayout.Toggle("canSubscribe?", this.client.canSubscribe); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Connect")) { this.client.Connect(); this.Repaint(); } if (GUILayout.Button("Disconnect")) { this.client.Disconnect(); this.Repaint(); } EditorGUILayout.EndHorizontal(); #region Available Queues //if (showAvailableQueues = EditorGUILayout.Foldout(showAvailableQueues, "Available Queues:")) //{ EditorGUILayout.BeginVertical("box"); foreach (var queue in this.client.GetQueues()) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Name:", queue.Name); if (GUILayout.Button("Subscribe", GUILayout.Width(30))) { this.client.SubscribeToQueue(queue.Name); } if (GUILayout.Button("X", GUILayout.Width(30))) { this.client.DeleteQueue(queue.Name); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); //} #endregion Available Queues #region Create Queue EditorGUILayout.BeginHorizontal("box"); this.queueName = EditorGUILayout.TextField("Queue Name", this.queueName); if (GUILayout.Button("Create")) { this.client.DeclareQueue(this.queueName); } EditorGUILayout.EndHorizontal(); #endregion // Create Queue #region Subscribe Queue AmqpQueue[] queues = this.client.GetQueues(); string[] names = new string[queues.Length]; for (int i = 0; i < queues.Length; i++) { names[i] = queues[i].Name; } selectedQueue = EditorGUILayout.Popup("Queue", selectedQueue, names); if (queues.Length != 0) { if (GUILayout.Button("Subscribe to " + names[this.selectedQueue] + " Queue")) { this.client.SubscribeToQueue(names[this.selectedQueue]); } } #endregion // Subscribe Queue if (this.client.ServerMode) { #region JobQueue string[] jobQueueNames = new string[this.client.GetQueues().Length]; for (int i = 0; i < this.client.GetQueues().Length; i++) { jobQueueNames[i] = this.client.GetQueues()[i].Name; } this.jobQueueIndex = EditorGUILayout.Popup("JobQueue", this.jobQueueIndex, jobQueueNames); for (int i = 0; i < jobQueueNames.Length; i++) { if (jobQueueNames[i] == "jobs") { this.jobQueueIndex = i; break; } } string jobQueueName = this.client.GetQueues().Length == 0 ? "not set" : jobQueueNames[this.jobQueueIndex]; //EditorGUILayout.LabelField("JobQueue", jobQueueName); #endregion // JobQueue #region ReplyQueue string[] replyToQueueNames = new string[this.client.GetQueues().Length]; for (int i = 0; i < this.client.GetQueues().Length; i++) { replyToQueueNames[i] = this.client.GetQueues()[i].Name; } this.replyQueueIndex = EditorGUILayout.Popup("ReplyToQueue", this.replyQueueIndex, replyToQueueNames); for (int i = 0; i < replyToQueueNames.Length; i++) { if (replyToQueueNames[i] == "reply") { this.replyQueueIndex = i; break; } } string replyQueueName = this.client.GetQueues().Length == 0 ? "not set" : replyToQueueNames[this.replyQueueIndex]; //EditorGUILayout.LabelField("ReplyToQueue", replyQueueName); #endregion // JobQueue #region JobQueue string[] statusUpdateQueueNames = new string[this.client.GetQueues().Length]; for (int i = 0; i < this.client.GetQueues().Length; i++) { statusUpdateQueueNames[i] = this.client.GetQueues()[i].Name; } this.statusUpdateQueueIndex = EditorGUILayout.Popup("ReplyToQueue", this.statusUpdateQueueIndex, statusUpdateQueueNames); for (int i = 0; i < statusUpdateQueueNames.Length; i++) { if (statusUpdateQueueNames[i] == "statusUpdates") { this.statusUpdateQueueIndex = i; break; } } string statusUpdateQueueName = this.client.GetQueues().Length == 0 ? "not set" : statusUpdateQueueNames[this.statusUpdateQueueIndex]; //EditorGUILayout.LabelField("ReplyToQueue", replyQueueName); #endregion // JobQueue EditorGUILayout.BeginVertical("box"); TileManager.TileWidth = (double)EditorGUILayout.FloatField("TileWidth", (float)TileManager.TileWidth); TileManager.tileRadius = EditorGUILayout.IntField("TileRadius", TileManager.tileRadius); TileManager.LOD = EditorGUILayout.IntField("LOD", TileManager.LOD); TileManager.OriginLatitude = (double)EditorGUILayout.FloatField("OriginLatitude", (float)TileManager.OriginLatitude); TileManager.OriginLongitude = (double)EditorGUILayout.FloatField("OriginLongitude", (float)TileManager.OriginLongitude); EditorGUILayout.EndVertical(); this.client.method = (SerializationMethod)EditorGUILayout.EnumPopup("SerializationMethod", this.client.method); if (GUILayout.Button("Send OSM-Job-Messages")) { this.client.SendOSMJobMessages( jobQueueName, replyQueueName, statusUpdateQueueName, TileManager.tileRadius, TileManager.TileWidth, TileManager.OriginLongitude, TileManager.OriginLatitude, this.client.method); } if (GUILayout.Button("Generate locally")) { mainScene = EditorSceneManager.GetActiveScene(); swComplete.Start(); tiles = new List <Tile>(); for (int i = -TileManager.tileRadius; i <= TileManager.tileRadius; i++) { for (int j = -TileManager.tileRadius; j <= TileManager.tileRadius; j++) { jobs++; Stopwatch sw = new Stopwatch(); sw.Reset(); sw.Start(); Tile newTile = Tile.CreateTileGO(i, j, 5); tiles.Add(newTile); tileJobsLocal.Add(i + "/" + j, newTile); tileJobsStopwatchLocal.Add(i + "/" + j, sw); //newTile.ProceduralDone += GenerationDone; //newTile.StartQuery(); //EditorSceneManager.SaveScenes //SceneManager.SetActiveScene(mainScene); } } tiles[0].ProceduralDone += GenerationDone; tiles[0].StartQuery(); } } else // Client-Mode { #region JobQueue string[] jobQueueNames = new string[this.client.GetQueues().Length]; for (int i = 0; i < this.client.GetQueues().Length; i++) { jobQueueNames[i] = this.client.GetQueues()[i].Name; } this.jobQueueIndex = EditorGUILayout.Popup("JobQueue", this.jobQueueIndex, jobQueueNames); string jobQueueName = this.client.GetQueues().Length == 0 ? "not set" : jobQueueNames[this.jobQueueIndex]; EditorGUILayout.LabelField("JobQueue", jobQueueName); if (jobQueueNames.Length != 0) { if (GUILayout.Button("Subscribe to " + jobQueueNames[this.jobQueueIndex] + " Queue")) { //this.client.BasicQos(1, 1, true); this.client.SubscribeToQueue(jobQueueNames[this.jobQueueIndex]); } } #endregion // JobQueue } GUI.backgroundColor = Color.white; EditorGUILayout.BeginVertical("box"); { foreach (StatusUpdateMessage item in SimpleClient.jobStatus.Values) { CustomGUIUtils.BeginGroup(); { switch (item.status) { case Status.PENDING: statusStyle = lightRed; break; case Status.IN_PROGRESS: statusStyle = lightYellow; break; case Status.DONE: statusStyle = lightGreen; break; default: statusStyle = GUIStyle.none; break; } EditorGUILayout.BeginHorizontal(statusStyle); EditorGUILayout.LabelField("" + item.jobID, GUILayout.Width(20f)); EditorGUILayout.LabelField("" + item.name, GUILayout.Width(80f)); EditorGUILayout.EndHorizontal(); foreach (string todo in item.childTodos) { CustomGUIUtils.BeginGroup(); TodoItem todoItem = item.childDict[todo]; switch (todoItem.status) { case Status.PENDING: statusStyle = lightRed; break; case Status.IN_PROGRESS: statusStyle = lightYellow; break; case Status.DONE: statusStyle = lightGreen; break; default: statusStyle = GUIStyle.none; break; } EditorGUILayout.BeginHorizontal(statusStyle); EditorGUILayout.LabelField(todoItem.name); EditorGUILayout.EndHorizontal(); DrawTodoItem(todoItem); CustomGUIUtils.EndGroup(); } } CustomGUIUtils.EndGroup(); } } EditorGUILayout.EndVertical(); // Save/serialized modified connection serializedObject.ApplyModifiedProperties(); // Update the last connection index lastIndex = index; }
public override void OnInspectorGUI() { GUILayout.Label("Behaviour_Node2D-Editor", EditorStyles.boldLabel); if (Selection.gameObjects.Length >= 2) { if (GUILayout.Button("Merge Nodes")) { GameObject node1 = Selection.gameObjects[0]; Node_Behaviour node1Behaviour = node1.GetComponent <Node_Behaviour>(); Node node1Node = node1Behaviour.Node; List <GameObject> mergeNodesGOs = new List <GameObject>(); List <Node> combineNodes = new List <Node>(); for (int i = 1; i < Selection.gameObjects.Length; i++) { GameObject node2 = Selection.gameObjects[1]; Node_Behaviour node2Behaviour = node2.GetComponent <Node_Behaviour>(); Node node2Node = node2Behaviour.Node; combineNodes.Add(node2Node); mergeNodesGOs.Add(node2); } node1Node.MergeWith(combineNodes.ToArray()); foreach (GameObject go in mergeNodesGOs) { DestroyImmediate(go); } } } EditorGUILayout.Separator(); EditorGUILayout.Separator(); //// Get Position from changes in the VectorField in Inspection Vector3 oldPosition = node.Position; Vector3 newPosition = EditorGUILayout.Vector3Field("Position", node.Position); if (oldPosition != newPosition) { Debug.Log("Auslöser Node2D-Editor-OnInspectorGUI"); node.Position = newPosition; nodeBehaviour.transform.position = newPosition; } if (nodeBehaviour != null && node != null) { EditorGUILayout.Separator(); if (edgesFoldout = EditorGUILayout.Foldout(edgesFoldout, "Edges")) { CustomGUIUtils.BeginGroup(); if (arrivalsFoldout = EditorGUILayout.Foldout(arrivalsFoldout, "Arrivals (" + node.ArrivalDegree.ToString() + ")")) { CustomGUIUtils.BeginGroup(); int count = 0; foreach (Edge edge in node.Arrivals) { EditorGUILayout.LabelField("Arrival " + count++, edge.Id); } CustomGUIUtils.EndGroup(); } if (departuresFoldout = EditorGUILayout.Foldout(departuresFoldout, "Departures (" + node.DepartureDegree.ToString() + ")")) { CustomGUIUtils.BeginGroup(); int count = 0; foreach (Edge edge in node.Departures) { EditorGUILayout.LabelField("Departure " + count++, edge.Id); } CustomGUIUtils.EndGroup(); } if (EditorGUILayout.Foldout(listenerFoldout, "Listeners")) { CustomGUIUtils.BeginGroup(); int count = 0; foreach (string name in node.PrintEventHandlers()) { EditorGUILayout.LabelField("" + count++, name); } CustomGUIUtils.EndGroup(); } CustomGUIUtils.EndGroup(); } } EditorGUILayout.Separator(); EditorGUILayout.Separator(); if (advancedGizmoSettings = EditorGUILayout.Foldout(advancedGizmoSettings, "Behaviour_Edge2D-Advanced-Gizmo-Settings")) { CustomGUIUtils.BeginGroup(); Node_Behaviour.NodeGizmoSize = (Node_Behaviour.GizmoSize)EditorGUILayout.EnumPopup("GizmoSize", Node_Behaviour.NodeGizmoSize); Node_Behaviour.DrawLabels = EditorGUILayout.Toggle("Show Label", Node_Behaviour.DrawLabels); nodeBehaviour.DrawHelpLinesGizmo = EditorGUILayout.Toggle("Show Help-Lines", nodeBehaviour.DrawHelpLinesGizmo); nodeBehaviour.DrawSecondLevelHelpLinesGizmo = EditorGUILayout.Toggle("Show SecondLevel Help-Lines", nodeBehaviour.DrawSecondLevelHelpLinesGizmo); Node_Behaviour.DrawAnglePieGizmoMaster = EditorGUILayout.Toggle("Draw Angle-Pie Gizmo", Node_Behaviour.DrawAnglePieGizmoMaster); if (Node_Behaviour.DrawAnglePieGizmoMaster) { CustomGUIUtils.BeginGroup(); nodeBehaviour.DrawAnglePieGizmo = EditorGUILayout.Toggle("Draw Angle-Pie Gizmo", nodeBehaviour.DrawAnglePieGizmo); if (nodeBehaviour.DrawAnglePieGizmo) { Node_Behaviour.DrawAnglePieGizmoDynamic = EditorGUILayout.Toggle("Dynamic Radius", Node_Behaviour.DrawAnglePieGizmoDynamic); if (!Node_Behaviour.DrawAnglePieGizmoDynamic) { nodeBehaviour.AnglePieGizmoRadius = EditorGUILayout.Slider("Radius", nodeBehaviour.AnglePieGizmoRadius, 0f, 10f); } } CustomGUIUtils.EndGroup(); } CustomGUIUtils.EndGroup(); } EditorGUILayout.Separator(); EditorGUILayout.Separator(); // Draw the DefaultInspector for this Behvaiour showDefaultInspector = this.DrawDefaultInspectorFoldout(nodeBehaviour, showDefaultInspector); if (GUI.changed) { EditorUtility.SetDirty(nodeBehaviour); } }
/// <summary> /// GUI of the FlatEarthCreator /// </summary> public void OnGUI() { clients = FindObjectsOfType <SimpleClient>(); if (clients == null) { GUILayout.Label("No Clients available...", lightRed); Debug.Log("No Clients available..."); return; } if (clients.Length == 0) { GUILayout.Label("No Clients available...", lightRed); Debug.Log("No Clients available.."); return; } foreach (SimpleClient item in clients) { if (item.ServerMode) { client = item; break; } } if (client == null) { return; } CheckDone(); GUILayout.BeginArea(new Rect(0, 0, position.width, 39), CustomGUIUtils.GetColorBackgroundStyle(XKCDColors.Bluegrey)); CustomGUIUtils.BeginGroup(5); GUILayout.BeginHorizontal(); Color normalColor = GUI.backgroundColor; GUI.backgroundColor = selectedMenu == 0 ? XKCDColors.LightGrey : Color.grey; if (GUILayout.Button("Client Settings", GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight)) || selectedMenu == 0) { selectedMenu = 0; } GUI.backgroundColor = selectedMenu == 1 ? XKCDColors.LightGrey : Color.grey; if (GUILayout.Button("FlatEarth Creation", GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight)) || selectedMenu == 1) { selectedMenu = 1; } GUI.backgroundColor = selectedMenu == 2 ? XKCDColors.LightGrey : Color.grey; if (GUILayout.Button("Worker Status", GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight)) || selectedMenu == 2) { selectedMenu = 2; } GUI.backgroundColor = normalColor; if (GUILayout.Button("Reset Everything", GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight))) { client.ResetMaster(); startTime = null; stopTime = null; } #region Timer string timer; if (stopTime == null) { timer = startTime != null?startTime.Duration() : "00:00:00.000"; } else { timer = TimeStamp.Duration(TimeStamp.Duration(startTime, stopTime)); } if (timerFontStyle == null) { timerFontStyle.font = (Font)Resources.Load("digitalmono"); timerFontStyle.fontSize = 34; } EditorGUI.LabelField(new Rect(this.position.width - 190, 0, 180, 20), timer, timerFontStyle); #endregion // Timer GUI.backgroundColor = normalColor; GUILayout.EndHorizontal(); CustomGUIUtils.EndGroup(); GUILayout.EndArea(); GUILayout.Space(buttonHeight + 20); switch (selectedMenu) { case 0: // Client Settings ClientSettingsGUI(); break; case 1: // FlatEarth Creation JobCreationGUI(); break; case 2: // Worker Status WorkerStatusGUI(); break; default: break; } }