It's hard to do lightmap smooth transitions in unity, which can only be achieved by switching buttons. The difficulty is the loading of multiple sets of lightmap, and how to replace them.
Steps:
1. Create a UI
<ignore_js_op>
<ignore_js_op>
3. Edit JS
[AppleScript]Plain Text view copy code ?
| 01020304050607080910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
var lightmapDay:Texture2D[];//第一套图var lightmapNight:Texture2D[];//第二套图private var lightDataFirst:LightmapData[];//第一套图的数据结构private var lightDataSecond:LightmapData[];//第二套图的数据结构private var ok:boolean=true;//切换开关private var indexnum:int;//每套图的数量。注意两套图要一样多,并且序号要一致function Start () {//初始化数据结构 indexnum=lightmapDay.Length;lightDataFirst=new LightmapData[indexnum];lightDataSecond=new LightmapData[indexnum];if(ok){//将两套图写入数据结构for(var i=0;i<indexnum;i++){ lightDataFirst[i]=new LightmapData();lightDataFirst[i].lightmapFar=lightmapDay[i];lightDataSecond[i]=new LightmapData();lightDataSecond[i].lightmapFar=lightmapNight[i];}}}function OnMouseDown () {if(ok){LightmapSettings.lightmaps=lightDataFirst;//切入第一套图}else{LightmapSettings.lightmaps=lightDataSecond;//切入第二套图}ok=!ok;} |
4. Add JS to the UI
Summary: This problem is solved by lightmapdata,lightmapsettings the two structures of mastery.
Game Bull: http://www.unitymanual.com
Unity3d lightmap map Load, replace, toggle