Unity-Lightmap-Prefab-Baker
Unity-Lightmap-Prefab-Baker copied to clipboard
Couldn't create asset file / [PrefabBaker] Failed to create asset
Hi, when I perform a bake on a parent object with some childed geometry and the Prefab Baker script attached, I can see a lightmap being created in the Baked Lightmaps tab. I can also observe the baking process in the Scene view. However, when the bake is done, Unity 2019.3.10f1 produces two critical errors:
This one first:
Couldn't create asset file!
UnityEditor.AssetDatabase:CreateAsset(Object, String)
PrefabLightMapBaker.EditorUtils:SaveLightmapAsset(String, String) (at Assets/Plugins/PrefabBaker/Scripts/Editor/EditorUtils.cs:202)
PrefabLightMapBaker.Baker:SaveSceneLightmap(Int32, String) (at Assets/Plugins/PrefabBaker/Scripts/Editor/Baker.cs:218)
PrefabLightMapBaker.Baker:GetOrSaveSceneLightmapToAsset(Int32, String) (at Assets/Plugins/PrefabBaker/Scripts/Editor/Baker.cs:156)
PrefabLightMapBaker.<>c__DisplayClass8_0:<SaveLightmaps>b__1(MeshRenderer) (at Assets/Plugins/PrefabBaker/Scripts/Editor/Baker.cs:129)
System.Collections.Generic.List1:ForEach(Action
1)
PrefabLightMapBaker.<>c:<SaveLightmaps>b__8_0(PrefabBaker) (at Assets/Plugins/PrefabBaker/Scripts/Editor/Baker.cs:129)
System.Collections.Generic.List1:ForEach(Action
1)
PrefabLightMapBaker.Baker:SaveLightmaps() (at Assets/Plugins/PrefabBaker/Scripts/Editor/Baker.cs:123)
PrefabLightMapBaker.Baker:OnBakeComplete() (at Assets/Plugins/PrefabBaker/Scripts/Editor/Baker.cs:90)
UnityEditor.Lightmapping:Internal_CallBakeCompletedFunctions()
Then this one:
[PrefabBaker] Failed to created asset:
from: Assets\Scenes/Creating Scene/Lightmap-0_comp_light.exr
to: D:/Unity/PrefabBakingTest/Assets/Resources/Lightmaps/ParentObject/ParentObject_light-0.asset
UnityEngine.Debug:LogError(Object)
PrefabLightMapBaker.EditorUtils:SaveLightmapAsset(String, String) (at Assets/Plugins/PrefabBaker/Scripts/Editor/EditorUtils.cs:206)
PrefabLightMapBaker.Baker:SaveSceneLightmap(Int32, String) (at Assets/Plugins/PrefabBaker/Scripts/Editor/Baker.cs:206)
PrefabLightMapBaker.Baker:GetOrSaveSceneLightmapToAsset(Int32, String) (at Assets/Plugins/PrefabBaker/Scripts/Editor/Baker.cs:156)
PrefabLightMapBaker.<>c__DisplayClass8_0:<SaveLightmaps>b__1(MeshRenderer) (at Assets/Plugins/PrefabBaker/Scripts/Editor/Baker.cs:129)
System.Collections.Generic.List1:ForEach(Action
1)
PrefabLightMapBaker.<>c:<SaveLightmaps>b__8_0(PrefabBaker) (at Assets/Plugins/PrefabBaker/Scripts/Editor/Baker.cs:129)
System.Collections.Generic.List1:ForEach(Action
1)
PrefabLightMapBaker.Baker:SaveLightmaps() (at Assets/Plugins/PrefabBaker/Scripts/Editor/Baker.cs:123)
PrefabLightMapBaker.Baker:OnBakeComplete() (at Assets/Plugins/PrefabBaker/Scripts/Editor/Baker.cs:90)
UnityEditor.Lightmapping:Internal_CallBakeCompletedFunctions()
In the end, I don't see Preview Scene Lightmaps, nor does the lightmapped prefab have any lights on it when I put it into another scene. Hope you can help. It would be much appreciated!
Apologies, I did not realize the bake has to be performed in the prefab editor (the one with the blue background), and that the light has to be added to the prefab. If I add a light to the prefab there and bake then, the light maps get created correctly. I can also place the baked prefab in a new scene, but only once. If I place it a 2nd time, the lightmapping is lost. Would there be a way to use the same baked prefab multiple times in a new scene?
It definitely should be possible , I bet it breaks in the Apply method in Scripts/Utils.cs , ill check it out soon
I had the same issues as @mgrugl
I fixed it by leaving the Lightmaps folder to default and creating in my assets folder this filepath Assets/Resources/Lightmaps
. Did not work when I specified a custom filepath
I had the same issue, but I think I fixed it by changing line 200 inside EditorUtils.cs from Directory.CreateDirectory( Directory.GetParent( saveTo ).FullName ); to Directory.CreateDirectory( Directory.GetParent( saveTo ).Name );
Hi! I had the same problem but did not find any solution, any update?
Its a Helpful tool, i just create a quick hack to solve the problems in Unity2021, hope it help
- fix custom lightmap folder
- fix renderer that has receiveGI = LightProbe Editor.zip
Its a Helpful tool, i just create a quick hack to solve the problems in Unity2021, hope it help
- fix custom lightmap folder
- fix renderer that has receiveGI = LightProbe Editor.zip
It worked. Thanks a lot man.
Its a Helpful tool, i just create a quick hack to solve the problems in Unity2021, hope it help
* fix custom lightmap folder * fix renderer that has receiveGI = LightProbe [Editor.zip](https://github.com/nukadelic/Unity-Lightmap-Prefab-Baker/files/7111402/Editor.zip)
nice , if u got the time make a merge request ill add it