Switch Lightmaps at runtime Unity 5
Hello,
In my project I have 4 Lightmaps depends of the Weather and the time (day/night)
I try many things, but nothing works !
Actually I have a WeatherManager, with some Array (0 = day_clear, 1 = day_rain, 2 night_clear and 3 = night_rain), an array know the folder name wich contain the texture2D in Resources (lightmapDataNameArray) and another array know how many texture are contain in this folder (lightmapDataNumberArray)
So I try these :
LightmapData[] tempLightmapDataArray = new LightmapData[lightmapDataNumberArray[targetWeatherID]];
for (int i = 0; i < lightmapDataNumberArray[targetWeatherID]; i++)
{
tempLightmapDataArray[i] = new LightmapData();
tempLightmapDataArray[i].lightmapNear = Resources.Load("Lightmaps/" + lightmapDataNameArray[targetWeatherID] + "/Lightmap-" + i + "_comp_dir", typeof(Texture2D)) as Texture2D;
tempLightmapDataArray[i].lightmapFar = Resources.Load("Lightmaps/" + lightmapDataNameArray[targetWeatherID] + "/Lightmap-" + i + "_comp_light", typeof(Texture2D)) as Texture2D;
}
LightmapSettings.lightmaps = tempLightmapDataArray;
if I go in Lighting Window, I see all the Texture correctly set, but they are not here in my scene (I can see theme if I classicly load my texture with the LightingDataAsset)
And if I have a LightDataAsset load in my scene before play, the result is really broken and different (even if I load the good LightDataAsset)
I'm on Unity5.4.0f3
If someone have a solution, I tried all code i found on google about these, but nothing works
Thank you for your help !
PS: sorry, it's my first post, and I'm not native english ! ^^