Unity更新版本之后经常需要重新烘焙场景,有的项目场景数量比较多,一个个手动烘焙太蛋疼。
using UnityEditor;
using UnityEditor.SceneManagement;
class SceneEditor
{
[MenuItem("BabybusFrame/场景/Bake Scenes In Build")]
private static void Bake()
{
var activeScene = EditorSceneManager.GetActiveScene().path;
foreach (var scene in EditorBuildSettings.scenes)
{
if (!scene.enabled)
continue;
EditorSceneManager.OpenScene(scene.path, OpenSceneMode.Single);
Lightmapping.Bake();
EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo();
}
if (activeScene != "")
EditorSceneManager.OpenScene(activeScene);
}
}
网友评论