using System.IO;
using UnityEditor;
using UnityEngine;
public class SceneInBuild : Editor
{
private static readonly string scenePath = "Scenes";
[MenuItem("Tool/BuildMainScene")]
static void RefreshAllScene()
{
string path = Path.Combine(Application.dataPath, scenePath);
string[] files = Directory.GetFiles(path, "*.unity", SearchOption.AllDirectories);
EditorBuildSettingsScene[] scenes = new EditorBuildSettingsScene[files.Length];
for (int i = 0; i < files.Length; ++i)
{
int index = files[i].IndexOf("Assets");
string _path = files[i].Remove(0, index);
scenes[i] = new EditorBuildSettingsScene(_path, true);
}
EditorBuildSettings.scenes = scenes;
}
}
场景放在Assets/Scenes下,根据需求更改
|