Created
October 20, 2024 00:36
-
-
Save redseiko/fa0be6a43f918b4bc891ef5a5c9968b0 to your computer and use it in GitHub Desktop.
Revisions
-
redseiko created this gist
Oct 20, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ using UnityEditor; using UnityEditor.SceneManagement; using UnityEngine; using UnityEngine.SceneManagement; [InitializeOnLoad] public static class ResetLightingDataAsset { static ResetLightingDataAsset() { EditorSceneManager.sceneOpened += OnSceneOpened; } // Create an brand new Scene and swap to it first to get this assigned. // TODO: just get the asset via hard-coded string. static LightingDataAsset _builtinLightingDataAsset; private static void OnSceneOpened(Scene scene, OpenSceneMode mode) { Debug.Log($"Scene: {scene.name} opened."); Debug.Log($"LightingDataAsset is: {Lightmapping.lightingDataAsset}"); if (Lightmapping.lightingDataAsset) { Debug.Log($"Path: {AssetDatabase.GetAssetPath(Lightmapping.lightingDataAsset.GetInstanceID())}"); if (!_builtinLightingDataAsset) { _builtinLightingDataAsset = Lightmapping.lightingDataAsset; } } else if (_builtinLightingDataAsset) { Debug.Log($"Setting to builtin one"); Lightmapping.lightingDataAsset = _builtinLightingDataAsset; EditorSceneManager.SaveScene(scene); } } }