public static bool CheckBuildSynchronized(MadLevelConfiguration config) { var scenes = EditorBuildSettings.scenes; if (config.levels.Count == 0) { // do not synchronize anything if it's nothing there return true; } if (scenes.Length == 0 && config.levels.Count > 0 || scenes.Length > 0 && config.levels.Count == 0) { // Debug.Log("Failed size test"); return false; } if (scenes.Length == 0 && config.levels.Count == 0) { return true; } var firstLevel = config.GetLevel(0); // check if first scene is my first scene if (scenes[0].path != firstLevel.scenePath) { // Debug.Log("Different start scene"); return false; } // find all configuration scenes that are not in build List<MadLevelScene> allScenes = new List<MadLevelScene>(); foreach (var level in config.levels) { allScenes.Add(level); } foreach (var extension in config.extensions) { allScenes.AddRange(extension.scenesBefore); allScenes.AddRange(extension.scenesAfter); } foreach (var level in allScenes) { if (!level.IsValid()) { continue; } var obj = Array.Find(scenes, (scene) => scene.path == level.scenePath); if (obj == null) { // scene not found in build // Debug.Log("Scene not found in build: " + item.level.scene); return false; } } return true; }
public void LoadLevel() { if (hasLevelConfiguration) { var level = configuration.GetLevel(MadLevel.Type.Level, levelIndex); MadLevel.LoadLevelByName(level.name); } else { if (!string.IsNullOrEmpty(levelSceneName)) { MadLevelProfile.recentLevelSelected = level.name; MadLevel.currentLevelName = level.name; MadLevel.arguments = ""; Application.LoadLevel(levelSceneName); } else { Debug.LogError("Level scene name not set. I don't know what to load!"); return; } } }