public override void OnGUI(MazeCreationWorkflowBackEnd backend) { var selectedMaze = backend.selectedMaze; var pathController = selectedMaze.GetComponent <PathController>(); if (pathController == null) { pathController = selectedMaze.gameObject.AddComponent <PathController>(); } var pathIds = pathController.GetAvailablePathIDs(); if (pathIds.Any()) { var options = pathIds.Select(i => string.Format("{0} - Path", i)).ToArray(); selected = EditorGUILayout.Popup(selected, options); pathToEdit = pathController.Paths.First(p => p.ID == pathIds[selected]); pathToEdit = EditorGUILayout.ObjectField("Edit: ", pathToEdit, typeof(PathInMaze), allowSceneObjects: true) as PathInMaze; pathToEdit.ID = EditorGUILayout.IntField("ID: ", pathToEdit.ID); } if (GUILayout.Button("Add new Path")) { var newPath = selectedMaze.gameObject.AddComponent <PathInMaze>(); if (pathController.Paths.Count() > 0) { var availableIds = pathController.GetAvailablePathIDs(); newPath.ID = availableIds.Max() + 1; } else { newPath.ID = 0; } pathController.Paths.Add(newPath); } if (backend.selectedMazeHasAPrefab() && GUILayout.Button("Save Path")) { backend.indicateChange(); } if (GUILayout.Button("Remove Selected Path")) { pathController.Paths.Remove(pathToEdit); Editor.DestroyImmediate(pathToEdit); pathToEdit = null; selected = 0; } }
public override void OnGUI(MazeCreationWorkflowBackEnd backend) { if (!CurrentSelection.Any()) { EditorGUILayout.HelpBox("Select Units first", MessageType.None); } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Remove Walls")) { TryConnectingCurrentSelection(); backend.indicateChange(); } if (GUILayout.Button("Add Walls")) { TryDisconnectingCurrentSelection(); backend.indicateChange(); } EditorGUILayout.EndHorizontal(); }