Unity3d lightmap map Load, replace, toggle

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.