Unity3D 批处理场景的工具
//场景的批量处理器 public static class OperateScene { public const string SceneDir = "Assets/Scene/"; public const string SceneNamePrefix = "Scene_"; public const string SceneNameExt = ".unity"; public const int SceneCount = 16; private static void OperateSceneMenu(Action<int ,Scene , GameObject[]> call) { for (int i = 0; i < SceneCount; i++) { int idx = i + 1; var scenePath = Path.Combine(SceneDir, SceneNamePrefix + idx + SceneNameExt); try { var scene = EditorSceneManager.OpenScene(scenePath, OpenSceneMode.Additive); EditorUtility.DisplayProgressBar("OperateSceneMenu", scenePath, i / SceneCount); var gos = scene.GetRootGameObjects(); call(i,scene, gos); EditorSceneManager.SaveScene(scene); EditorSceneManager.CloseScene(scene, true); } catch (Exception e) { Debug.LogError(scenePath+"\n"+e.Message); } } EditorUtility.ClearProgressBar(); }
传入一个回掉函数就可以了