/// <summary> /// Adds all scenes from profile into build settings. /// </summary> private void EditorUpdateBuildSettings() { if (!profile.EditorManageBuildSettings) { // Nothing to do here return; } if (profile.UseManagerScene) { if (EditorSceneUtils.AddSceneToBuildSettings( profile.ManagerScene, cachedBuildScenes, EditorSceneUtils.BuildIndexTarget.First)) { cachedBuildScenes = EditorBuildSettings.scenes; } } foreach (SceneInfo contentScene in profile.ContentScenes) { if (EditorSceneUtils.AddSceneToBuildSettings( contentScene, cachedBuildScenes, EditorSceneUtils.BuildIndexTarget.None)) { cachedBuildScenes = EditorBuildSettings.scenes; } } if (profile.UseLightingScene) { foreach (SceneInfo lightingScene in profile.LightingScenes) { // Make sure ALL lighting scenes are added to build settings if (EditorSceneUtils.AddSceneToBuildSettings( lightingScene, cachedBuildScenes, EditorSceneUtils.BuildIndexTarget.Last)) { cachedBuildScenes = EditorBuildSettings.scenes; } } } EditorCheckForSceneNameDuplicates(); }
public override void OnInspectorGUI() { if (!MixedRealityToolkit.IsInitialized) { return; } RenderProfileHeader(ProfileTitle, ProfileDescription, target); MixedRealityInspectorUtility.CheckMixedRealityConfigured(true); serializedObject.Update(); MixedRealitySceneSystemProfile profile = (MixedRealitySceneSystemProfile)target; RenderFoldout(ref showEditorProperties, "Editor Settings", () => { using (new EditorGUI.IndentLevelScope()) { EditorGUILayout.PropertyField(editorManageBuildSettings); EditorGUILayout.PropertyField(editorManageLoadedScenes); EditorGUILayout.PropertyField(editorEnforceSceneOrder); EditorGUILayout.PropertyField(editorEnforceLightingSceneTypes); if (editorEnforceLightingSceneTypes.boolValue) { EditorGUILayout.Space(); EditorGUILayout.HelpBox("Below are the component types that will be allowed in lighting scenes. Types not found in this list will be moved to another scene.", MessageType.Info); EditorGUIUtility.labelWidth = LightingSceneTypesLabelWidth; EditorGUILayout.PropertyField(permittedLightingSceneComponentTypes, true); EditorGUIUtility.labelWidth = 0; } } }, ShowSceneSystem_Editor_PreferenceKey); RenderFoldout(ref showManagerProperties, "Manager Scene Settings", () => { using (new EditorGUI.IndentLevelScope()) { EditorGUILayout.HelpBox(managerSceneContent, MessageType.Info); // Disable the tag field since we're drawing manager scenes SceneInfoDrawer.DrawTagProperty = false; EditorGUILayout.PropertyField(useManagerScene); if (useManagerScene.boolValue && profile.ManagerScene.IsEmpty && !Application.isPlaying) { EditorGUILayout.HelpBox("You haven't created a manager scene yet. Click the button below to create one.", MessageType.Warning); var buttonRect = EditorGUI.IndentedRect(EditorGUILayout.GetControlRect(new GUILayoutOption[] { })); if (GUI.Button(buttonRect, "Create Manager Scene", EditorStyles.miniButton)) { // Create a new manager scene and add it to build settings SceneInfo newManagerScene = EditorSceneUtils.CreateAndSaveScene("ManagerScene"); SerializedObjectUtils.SetStructValue <SceneInfo>(managerScene, newManagerScene); EditorSceneUtils.AddSceneToBuildSettings(newManagerScene, EditorBuildSettings.scenes, EditorSceneUtils.BuildIndexTarget.First); } EditorGUILayout.Space(); } if (useManagerScene.boolValue) { EditorGUILayout.PropertyField(managerScene, includeChildren: true); } } }, ShowSceneSystem_Manager_PreferenceKey); RenderFoldout(ref showLightingProperties, "Lighting Scene Settings", () => { using (new EditorGUI.IndentLevelScope()) { EditorGUILayout.HelpBox(lightingSceneContent, MessageType.Info); EditorGUILayout.PropertyField(useLightingScene); if (useLightingScene.boolValue && profile.NumLightingScenes < 1 && !Application.isPlaying) { EditorGUILayout.HelpBox("You haven't created a lighting scene yet. Click the button below to create one.", MessageType.Warning); var buttonRect = EditorGUI.IndentedRect(EditorGUILayout.GetControlRect(new GUILayoutOption[] { })); if (GUI.Button(buttonRect, "Create Lighting Scene", EditorStyles.miniButton)) { // Create a new lighting scene and add it to build settings SceneInfo newLightingScene = EditorSceneUtils.CreateAndSaveScene("LightingScene"); // Create an element in the array lightingScenes.arraySize = 1; serializedObject.ApplyModifiedProperties(); SerializedObjectUtils.SetStructValue <SceneInfo>(lightingScenes.GetArrayElementAtIndex(0), newLightingScene); EditorSceneUtils.AddSceneToBuildSettings(newLightingScene, EditorBuildSettings.scenes, EditorSceneUtils.BuildIndexTarget.Last); } EditorGUILayout.Space(); } if (useLightingScene.boolValue) { // Disable the tag field since we're drawing lighting scenes SceneInfoDrawer.DrawTagProperty = false; if (profile.NumLightingScenes > 0) { string[] lightingSceneNames = profile.LightingScenes.Select(l => l.Name).ToArray <string>(); defaultLightingSceneIndex.intValue = EditorGUILayout.Popup("Default Lighting Scene", defaultLightingSceneIndex.intValue, lightingSceneNames); } EditorGUILayout.PropertyField(lightingScenes, includeChildren: true); //DrawSceneInfoDragAndDrop(lightingScenes); EditorGUILayout.Space(); if (profile.NumLightingScenes > 0) { if (profile.EditorLightingCacheOutOfDate) { EditorGUILayout.HelpBox("Your cached lighting settings may be out of date. This could result in unexpected appearances at runtime.", MessageType.Warning); } if (InspectorUIUtility.RenderIndentedButton(new GUIContent("Update Cached Lighting Settings"), EditorStyles.miniButton)) { profile.EditorLightingCacheUpdateRequested = true; } } EditorGUILayout.Space(); } } }, ShowSceneSystem_Lighting_PreferenceKey); RenderFoldout(ref showContentProperties, "Content Scene Settings", () => { using (new EditorGUI.IndentLevelScope()) { EditorGUILayout.HelpBox(contentSceneContent, MessageType.Info); // Enable the tag field since we're drawing content scenes SceneInfoDrawer.DrawTagProperty = true; EditorGUILayout.PropertyField(contentScenes, includeChildren: true); //DrawSceneInfoDragAndDrop(contentScenes); } }, ShowSceneSystem_Content_PreferenceKey); serializedObject.ApplyModifiedProperties(); // Keep this inspector perpetually refreshed EditorUtility.SetDirty(target); }