Search Unity

Loaded Lightmaps Clearing On Play

Discussion in 'Editor & General Support' started by AlexJBoyd, Oct 21, 2015.

  1. AlexJBoyd

    AlexJBoyd

    Joined:
    Dec 6, 2012
    Posts:
    8
    I am working on an editor tool that will allow 3D artist to load in lightmaps baked in external programs. I had the system working as two scripts that ran things on Awake - one to create the lightmaps, and the other to apply to certain renders.

    However, I decided it would work better to be an editor tool that way so many things aren't happening when a scene initializes.

    The problem is that once the lightmaps are loaded into the lightmap arrray (which I can see in the "lighting" tab) and I hit play, all the data is gone. Why is this data getting cleared? Do I really need to only do this in runtime?

    Here is a sample of the code:

    LightmapData mapdataSave = new LightmapData();
    mapdataSave.lightmapNear = tempNearMap;
    mapdataSave.lightmapFar = tempFarMap;

    currentLightmaps.Add(mapdataSave);

    LightmapData[] currentLightmapsArray = new LightmapData[currentLightmaps.Count];
    for (int i = 0; i < currentLightmaps.Count; i++)
    {
    currentLightmapsArray = currentLightmaps;
    }

    LightmapSettings.lightmaps = currentLightmapsArray;