Editing Lightmaps At Edit Time

Hi all,

I’ve written an editor script which edits one of the beast lightmaps, colouring an object red in the lightmap.

To colour the object it uses:

LightmapSettings.lightmaps[lightmapIndex].lightmapFar.SetPixel((int)x, (int)y, Color.red);

Then applies the texture with:

LightmapSettings.lightmaps[lightmapIndex].lightmapFar.Apply();

This works great, the object is now red and in the lightmap preview it’s clearly red too.

However as soon as I hit save, the lightmap reverts to how it was baked by Beast. Any idea on how I commit these changes onto the actual .exr file in Unity?

needs an Unity - Scripting API: Texture2D.Apply after changing maybe?

I already do that :slight_smile:

I’m trying now to save the lightmap out as a second texture, but because the exported texture doesn’t have a texture importer I can’t flag it as a lightmap and it comes out too bright.