how to keep lightmap on Don'tDestroyOnLoad object ANSWERED use this script!!!

lightmaps are associated with each scene. when loading a new scene, the previous scene’s lightmaps are removed, even on an object using “Don’tDestroyOnLoad”. Whats up with that? The lightmaps are still in the assets folder, is there a way to load the one i need back onto the object at the start of the next scene?

Better yet, this script when added to any “DontDestroyOnLoad” object, will save it’s lightMap and add it to the end of the next scenes lightMapArray non destructively. Simply assign the renderer of the object, and call “SaveCurrentLightMap” before unloading the current scene and “ReloadLightMap” at the start of the next scene.

    Texture2D[] textures = new Texture2D[2];
    public Renderer rend;

    void Awake()

    public void SaveCurrentLightMap()
        textures[0] = LightmapSettings.lightmaps[rend.lightmapIndex].lightmapFar;
        textures[1] = LightmapSettings.lightmaps[rend.lightmapIndex].lightmapNear;

    public void ReloadLightMap()
        LightmapData[] lightmapData = new LightmapData[LightmapSettings.lightmaps.Length + 1];

        for (int i = 0; i < LightmapSettings.lightmaps.Length; i ++)
            lightmapData _= LightmapSettings.lightmaps*;*_


var lastIndex = lightmapData.Length - 1;

lightmapData[lastIndex] = new LightmapData();

lightmapData[lastIndex].lightmapFar = textures[0];
lightmapData[lastIndex].lightmapNear = textures[1];

LightmapSettings.lightmaps = lightmapData;

rend.lightmapIndex = lastIndex;