Hi guys , i'm working on some problems: 1.i want use this code below to switch lightmap in my scene public Texture2D lightmap1; LightmapData data=new LightmapData(); data.lightmapColor=lightmap1; LightmapSettings.Lightmaps=new LightmapData[1]{data}; 2.but there is a problem. there are three lightmaps in my lightmap folder,which should i use in the code?
If you want to switch lightmaps (for different lighting conditions or something I assume?), you need to change all three.
thanks for reply ,but I'm still confused , should I create a array contains all three lightmaps then give it to lighmapsettings.lightmaps? And what about the index of lightmaps?
Update: Fixed! using UnityEngine; public class LightMapSwitch : MonoBehaviour { public Texture2D[] dayMap; public Texture2D[] NightMap; private void OnGUI() { if (GUILayout.Button("<size=50>day</size>")) { foreach(Texture2D tex in dayMap) { Debug.Log(tex.ToString()); } LightmapData[] datas = new LightmapData[3]; for (int i= 0; i < datas.Length; i++) { LightmapData data= new LightmapData(); data.lightmapColor = dayMap[i]; datas[i] = data; } LightmapSettings.lightmaps = datas; } if (GUILayout.Button("<size=50>Night</size>")) { LightmapData[] datas = new LightmapData[3]; for (int i = 0; i < datas.Length; i++) { LightmapData data = new LightmapData(); data.lightmapColor = NightMap[i]; datas[i] = data; } LightmapSettings.lightmaps =datas; } } }