2024-12-14 00:14:40 +08:00
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
using UnityEditor;
|
2024-12-09 11:56:41 +08:00
|
|
|
|
using UnityEditor.SceneManagement;
|
2024-12-14 00:14:40 +08:00
|
|
|
|
using UnityEngine;
|
2024-12-09 11:56:41 +08:00
|
|
|
|
|
|
|
|
|
class SceneEditor
|
|
|
|
|
{
|
|
|
|
|
[MenuItem("Tools/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);
|
|
|
|
|
}
|
2024-12-14 00:14:40 +08:00
|
|
|
|
}
|
|
|
|
|
#endif
|