代码 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 #region 将场景添加到 Build Settings // 场景存放目录 var sceneDir = $"{Application.dataPath}/Scenes"; var sceneFiles = Directory.GetFiles(sceneDir, "*.unity", SearchOption.AllDirectories); var scenes = new EditorBuildSettingsScene[sceneFiles.Length]; for (var i = 0; i < sceneFiles.Length; i++) { // 替换斜杠 var sceneFile = sceneFiles[i].Replace("\\", "/"); // 使用相对路径 var assetsFolderIndex = sceneFile.IndexOf("Assets", StringComparison.Ordinal); sceneFile = sceneFile.Substring(assetsFolderIndex); var scene = new EditorBuildSettingsScene(sceneFile, true); scenes[i] = scene; } EditorBuildSettings.scenes = scenes; #endregion……
阅读全文