using System.Collections.Generic; using UnityEditor; // Следит, чтобы сцена карты мира (WorldMap, от Саши) была в Build Settings -- // иначе переход город -> карта не работает. Срабатывает сам после каждой компиляции. [InitializeOnLoad] public static class SceneListFixer { const string CityScene = "Assets/Scenes/MVP1.unity"; const string WorldScene = "Assets/Scenes/WorldMap.unity"; static SceneListFixer() { EditorApplication.delayCall += Ensure; } static void Ensure() { var scenes = new List(EditorBuildSettings.scenes); bool changed = false; foreach (var path in new[] { CityScene, WorldScene }) { if (AssetDatabase.LoadAssetAtPath(path) == null) continue; if (scenes.Exists(s => s.path == path)) continue; scenes.Add(new EditorBuildSettingsScene(path, true)); changed = true; } // город должен быть первым (с него стартует игра) int city = scenes.FindIndex(s => s.path == CityScene); if (city > 0) { var c = scenes[city]; scenes.RemoveAt(city); scenes.Insert(0, c); changed = true; } if (changed) { EditorBuildSettings.scenes = scenes.ToArray(); UnityEngine.Debug.Log("[СЦЕНЫ] Build Settings: город + карта мира добавлены"); } } }