public override void OnInspectorGUI() { bool roomsUpdated = false; RoomNode[] roomNodes = new RoomNode[targets.Length]; for (int i = 0; i < targets.Length; i++) { roomNodes[i] = (RoomNode)targets[i]; } bool[] diagonalLastValue = roomNodes.Select(rn => rn.isDiagonal).ToArray(); DrawDefaultInspector(); DrawSelectMeshPopup(roomNodes, ref roomsUpdated); for (var i = 0; i < roomNodes.Length; i++) { var roomNode = roomNodes[i]; if (diagonalLastValue[i] != roomNode.isDiagonal && roomNode.GetComponent <MeshFilter>()) { roomNode.meshIndex = 0; SetMesh(roomNode, roomNode.wallOrientation); roomsUpdated = true; } } Undo.RecordObjects(targets, "Orientation buttons"); OrientationButtons(roomNodes, ref roomsUpdated); if (GUILayout.Button("UpdateCollision") || roomsUpdated) { Undo.RecordObjects(targets, "Updating collision meshes"); foreach (var rn in roomNodes) { rn.UpdateCollisionMesh(); } } if (roomsUpdated) { foreach (var roomNode in roomNodes) { EditorUtility.SetDirty(roomNode); EditorSceneManager.MarkSceneDirty(roomNode.gameObject.scene); } } EditorGUILayout.Space(); if (GUILayout.Button("Refresh all rooms")) { var allRooms = FindObjectsOfType <RoomNode>(); Undo.RecordObjects(allRooms, "Refresh all rooms"); foreach (var room in allRooms) { if (room.GetComponent <MeshFilter>() ) //This is funky. @TODO: add "None" wall orientation. Rename wall kind? { SetMesh(room, room.wallOrientation, room.meshIndex); room.UpdateCollisionMesh(); } else { RenameNode(room, false); } } } }