public static RemoveSceneFromBuild ( string scene ) : void | ||
scene | string | |
return | void |
//TODO: Finish up and make public! public static bool ValidateBuildSettings(out List <string> invalidScenes) { SyncBuildSettings(); List <string> sceneList = ReadScenes(); invalidScenes = new List <string>(); foreach (string scene in sceneList) { string absoluteTextScene = EditorHelper.GetProjectFolder() + scene; //Make sure the scene exists at all in a TextScene format if (!File.Exists(absoluteTextScene)) { Debug.LogWarning("Scene does not exist: " + scene); EditorApplication.isPlaying = false; if (EditorUtility.DisplayDialog("Invalid scene", "The scene '" + scene + "' is listed in your build settings but it does not exist. Do you want to remove it from build settings?", "Yes", "No")) { TextScene.RemoveSceneFromBuild(scene); } else { invalidScenes.Add(scene); continue; } } else { //While the textscene might be present, we also need the binary temp file. //Make sure there is one up-to-date, if not, the user should be prompted //to generate one. string absoluteBinaryTempScene = EditorHelper.GetProjectFolder() + TextSceneToTempBinaryFile(scene); if (!File.Exists(absoluteBinaryTempScene)) { Debug.LogWarning("Temp scene does not exist: " + absoluteBinaryTempScene); //EditorApplication.isPlaying = false; //if (EditorUtility.DisplayDialog("Missing temp file", "Missing temp file for '" + scene + "' - do you want to generate it now?", "Yes", "No")) // TextSceneDeserializer.LoadSafe(absoluteTextScene); invalidScenes.Add(scene); continue; } else { //Both files exist, but we also need to make sure the temp scene isn't outdated. DateTime textSceneTime = File.GetLastWriteTime(absoluteTextScene); DateTime binaryTempSceneTime = File.GetLastWriteTime(absoluteBinaryTempScene); if (textSceneTime > binaryTempSceneTime) { Debug.LogWarning("Temp scene for '" + scene + "' is outdated: " + binaryTempSceneTime + " is older than " + textSceneTime); //EditorApplication.isPlaying = false; //if (EditorUtility.DisplayDialog("Outdated temp file", "Outdated temp file for '" + scene + "' - do you want to update it now?", "Yes", "No")) // TextSceneDeserializer.LoadSafe(absoluteTextScene); invalidScenes.Add(scene); continue; } } } } return(invalidScenes.Count == 0); }
void OnGUI() { GUILayout.BeginVertical(); scroll = GUILayout.BeginScrollView(scroll); GUILayout.Label("Scenes to build"); foreach (string scene in scenes) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(scene)) { TextSceneDeserializer.LoadSafe(EditorHelper.GetProjectFolder() + scene); GUIUtility.ExitGUI(); return; } if (GUILayout.Button("Remove", GUILayout.MaxWidth(60))) { if (EditorUtility.DisplayDialog("Remove scene", "Are you sure you want to remove this scene from the build settings?", "Yes", "No")) { TextScene.RemoveSceneFromBuild(scene); LoadSettings(); } } if (GUILayout.Button("+", GUILayout.MaxWidth(20))) { TextScene.MoveScenePosition(scene, 1); LoadSettings(); } if (GUILayout.Button("-", GUILayout.MaxWidth(20))) { TextScene.MoveScenePosition(scene, -1); LoadSettings(); } GUILayout.EndHorizontal(); } if (scenes.Count > 0) { EditorGUILayout.Separator(); EditorGUILayout.BeginVertical(GUILayout.MaxWidth(150)); if (GUILayout.Button("Build Temp")) { TextScene.BuildTempScenes(); GUIUtility.ExitGUI(); return; } if (GUILayout.Button("Build Streamed Web")) { TextScene.Build(BuildTarget.WebPlayerStreamed); GUIUtility.ExitGUI(); return; } if (GUILayout.Button("Build Web")) { TextScene.Build(BuildTarget.WebPlayer); GUIUtility.ExitGUI(); return; } if (GUILayout.Button("Build OSX")) { TextScene.Build(BuildTarget.StandaloneOSXUniversal); GUIUtility.ExitGUI(); return; } if (GUILayout.Button("Build Windows")) { TextScene.Build(BuildTarget.StandaloneWindows); GUIUtility.ExitGUI(); return; } EditorGUILayout.EndVertical(); } else { GUILayout.Label("Add scenes via the TextScene menu item to enable build"); } EditorGUILayout.Separator(); if (GUILayout.Button("Add current", GUILayout.MaxWidth(100))) { TextScene.AddCurrentSceneToBuild(); LoadSettings(); } EditorGUILayout.Separator(); if (GUILayout.Button("Validate Settings", GUILayout.MaxWidth(100))) { List <string> invalidScenes; if (TextScene.ValidateBuildSettings(out invalidScenes)) { EditorUtility.DisplayDialog("Valid settings", "The build settings seem valid enough", "OK"); } else { StringBuilder sb = new StringBuilder(); sb.Append("There were errors in validation: \n"); foreach (string scene in invalidScenes) { sb.Append(" "); sb.Append(scene); sb.Append('\n'); } sb.Append("Try running 'Build Temp' to fix them up, or inspect the console for further hints."); EditorUtility.DisplayDialog("Validation failed", sb.ToString(), "OK"); } } GUILayout.EndScrollView(); GUILayout.EndVertical(); }