/// <summary> /// Draws info box of the provided scene /// </summary> private void DrawSceneInfoGUI(Rect position, BuildUtils.BuildScene buildScene, int sceneControlID) { bool readOnly = BuildUtils.IsReadOnly(); string readOnlyWarning = readOnly ? "\n\nWARNING: Build Settings is not checked out and so cannot be modified." : ""; // Label Prefix GUIContent iconContent = new GUIContent(); GUIContent labelContent = new GUIContent(); // Missing from build scenes if (buildScene.buildIndex == -1) { iconContent = EditorGUIUtility.IconContent("d_winbtn_mac_close"); labelContent.text = "NOT In Build"; labelContent.tooltip = "This scene is NOT in build settings.\nIt will be NOT included in builds."; } // In build scenes and enabled else if (buildScene.scene.enabled) { iconContent = EditorGUIUtility.IconContent("d_winbtn_mac_max"); labelContent.text = "BuildIndex: " + buildScene.buildIndex; labelContent.tooltip = "This scene is in build settings and ENABLED.\nIt will be included in builds." + readOnlyWarning; } // In build scenes and disabled else { iconContent = EditorGUIUtility.IconContent("d_winbtn_mac_min"); labelContent.text = "BuildIndex: " + buildScene.buildIndex; labelContent.tooltip = "This scene is in build settings and DISABLED.\nIt will be NOT included in builds."; } // Left status label using (new EditorGUI.DisabledScope(readOnly)) { Rect labelRect = DrawUtils.GetLabelRect(position); Rect iconRect = labelRect; iconRect.width = iconContent.image.width + padSize; labelRect.width -= iconRect.width; labelRect.x += iconRect.width; EditorGUI.PrefixLabel(iconRect, sceneControlID, iconContent); EditorGUI.PrefixLabel(labelRect, sceneControlID, labelContent); } // Right context buttons Rect buttonRect = DrawUtils.GetFieldRect(position); buttonRect.width = (buttonRect.width) / 3; string tooltipMsg = ""; using (new EditorGUI.DisabledScope(readOnly)) { // NOT in build settings if (buildScene.buildIndex == -1) { buttonRect.width *= 2; int addIndex = EditorBuildSettings.scenes.Length; tooltipMsg = "Add this scene to build settings. It will be appended to the end of the build scenes as buildIndex: " + addIndex + "." + readOnlyWarning; if (DrawUtils.ButtonHelper(buttonRect, "Add...", "Add (buildIndex " + addIndex + ")", EditorStyles.miniButtonLeft, tooltipMsg)) { BuildUtils.AddBuildScene(buildScene); } buttonRect.width /= 2; buttonRect.x += buttonRect.width; } // In build settings else { bool isEnabled = buildScene.scene.enabled; string stateString = isEnabled ? "Disable" : "Enable"; tooltipMsg = stateString + " this scene in build settings.\n" + (isEnabled ? "It will no longer be included in builds" : "It will be included in builds") + "." + readOnlyWarning; if (DrawUtils.ButtonHelper(buttonRect, stateString, stateString + " In Build", EditorStyles.miniButtonLeft, tooltipMsg)) { BuildUtils.SetBuildSceneState(buildScene, !isEnabled); } buttonRect.x += buttonRect.width; tooltipMsg = "Completely remove this scene from build settings.\nYou will need to add it again for it to be included in builds!" + readOnlyWarning; if (DrawUtils.ButtonHelper(buttonRect, "Remove...", "Remove from Build", EditorStyles.miniButtonMid, tooltipMsg)) { BuildUtils.RemoveBuildScene(buildScene); } } } buttonRect.x += buttonRect.width; tooltipMsg = "Open the 'Build Settings' Window for managing scenes." + readOnlyWarning; if (DrawUtils.ButtonHelper(buttonRect, "Settings", "Build Settings", EditorStyles.miniButtonRight, tooltipMsg)) { BuildUtils.OpenBuildSettings(); } }