#if UNITY_EDITOR using System; using System.Linq; using UnityEditor; using UnityEditor.SceneManagement; using UnityEngine; using UnityEngine.SceneManagement; public static class PrepareBudBudFormal { public static string InspectScenes() { return string.Join("\n",Enumerable.Range(0,SceneManager.sceneCount).Select(i=> { var scene=SceneManager.GetSceneAt(i); return $"name={scene.name} path={scene.path} dirty={scene.isDirty} roots={scene.rootCount}: "+string.Join(",",scene.GetRootGameObjects().Select(g=>g.name)); })); } public static string SaveEmptyBatchStartup() { if(!Application.isBatchMode || EditorApplication.isPlaying || SceneManager.sceneCount!=1) throw new Exception("Only the empty batch startup scene may be saved here"); var scene=SceneManager.GetSceneAt(0); if(!string.IsNullOrEmpty(scene.path) || scene.rootCount!=0) throw new Exception("Existing scene content must be preserved untouched"); const string path="Assets/Temp/BudBud_BatchStartup_20261020.unity"; if(AssetDatabase.LoadAssetAtPath(path)!=null)throw new Exception("Startup archive already exists"); if(!AssetDatabase.IsValidFolder("Assets/Temp"))AssetDatabase.CreateFolder("Assets","Temp"); if(!EditorSceneManager.SaveScene(scene,path))throw new Exception("Cannot preserve empty startup scene"); return "Preserved empty batch startup: "+path; } public static string FinishBatch() { if(!Application.isBatchMode || EditorApplication.isPlaying)throw new Exception("Only finish this task's batch editor in Edit Mode"); foreach(var scene in Enumerable.Range(0,SceneManager.sceneCount).Select(SceneManager.GetSceneAt)) if(scene.isDirty || (scene.path!="Assets/Temp/BudBud_BatchStartup_20261020.unity" && scene.path!="Assets/Bundles/Scenes/Review/Companion_BudBud_Review.unity")) throw new Exception("Preserve existing scene state before closing"); EditorApplication.delayCall+=()=>EditorApplication.Exit(0); return "Closing this task's saved batch editor; other project editors untouched"; } public static string ArchiveDraft() { if(EditorApplication.isPlaying)throw new Exception("Archive in Edit Mode"); const string source="Assets/Bundles/Characters/Animal/BudBud"; const string target="Assets/Temp/BudBud_OfflineDraft_20261020"; if(AssetDatabase.IsValidFolder(target))return "Archive already exists: "+target; if(!AssetDatabase.IsValidFolder(source))throw new Exception("Missing existing BudBud draft"); if(!AssetDatabase.IsValidFolder("Assets/Temp"))AssetDatabase.CreateFolder("Assets","Temp"); if(!AssetDatabase.CopyAsset(source,target))throw new Exception("Cannot preserve BudBud draft"); AssetDatabase.SaveAssets();AssetDatabase.Refresh(); return "Preserved draft with new archive GUIDs outside Bundles: "+target; } } #endif