Godot Version
4.7
Question
I have a custom node that extends Node3D and has a hidden child that is a MeshInstance3D. The node generates a mesh which is then put on the child MeshInstance3D. This generated mesh object includes UV2 coordinates, so it is possible to use it for baking lightmaps.
This works fine until I have to save and restore the file. When the scene reloads, the child mesh instance has it’s mesh object recreated, which doesn’t include the baked data from the LightmapGI.
There does seem to be a work around where I create the child MeshInstance3D in my object’s _init() method and then later force the LightmapGI to refresh by caching it’s light_data parameter, setting it to null and then setting it back to its old value again. But this seems like a poor solution, and I was wondering if there might be a better way to restore the cached lightmap data when I rebuild my mesh?