荣耀彩票代理

  • 热门专题

Unity性能优化(2)官方文档简译

作者:Alan777w  发布日期:2016-12-07 20:52:27
  •  

    简介

    RUGUOYOUXIYUNXINGHUANMAN,KADUN,WOMENZHIDAOYOUXICUNZAIXINGNENGWENTI。ZAIWOMENCHANGSHIJIEJUEWENTIQIAN,XUYAOXIANZHIDAOYINQIWENTIDEYUANYIN。BUTONGWENTIXUYAOBUTONGDEJIEJUEFANGAN。RUGUOWOMENKAOCAICEHUOZHEQITAXIANGMUDEJINGYANQUJIEJUEWENTI,NEIMEWOMENKENENGHUILANGFEIHENDUOSHIJIAN,SHENZHISHIDEWENTIGENGYANZHONG。

    ZHEISHIWOMENXUYAOXINGNENGFENXI,XINGNENGFENXICHENGXUCELIANGYOUXIYUNXINGSHIDEGEGEFANGMIANXINGNENG。TONGGUOXINGNENGFENXIGONGJU,WOMENNENGGOUTOUGUOYOUXIYUNXINGDECHANGJINGBIAOMIANBIAOXIAN,HUOQUSHENRUDEXINXI,TONGGUOZHEIXIEXINXI,WOMENKEYIZHUIZONGYINQIXINGNENGWENTIDEYUANYIN。TONGGUOXINGNENGFENXIGONGJU,DANGWOMENXIUGAIHOU,WOMENKEYICELIANGWOMENDEXIUGAISHIFOUYOUXIAO,SHIFOUXIUFULEXINGNENGWENTI。

    ZAIBENWENZHONG,WOMENJIANGHUI:

    荣耀彩票代理-SHIYONGUnityDENEIZHIXINGNENGFENXIGONGJUProfilerQUSHOUJIWOMENDEDIXINGNENGYOUXIDEYUNXINGSHISHUJU。

    -FENXISHUJU,BINGZHUIZONGYINQIXINGNENGWENTIDEYUANYIN

    -FENXIANGXIUFUZHEIXIETEDINGWENTIDEWENZHANGDELIANJIE

    SHIDEYOUXIYUNXINGKUAISUPINGHUASHIYIXIANGPINGHENGXINGDEGONGZUO。ZAIHUOQUWOMENXIANGYAODEJIEGUOQIAN,WOMENKENENGXUYAOHAOJILUNDEXIUGAI,BINGCELIANGXIAOGUO。ZHIDAORUHESHIYONGXINGNENGFENXIGONGJUFENXIWENTIYIWEIZHEWOMENNENGGOUQUERENNALICHULEWENTI,BINGQIELIJIEJIEXIALAIYINGGAIZENMEYANGCHANGSHIXIUGAI。

    开始之前

    荣耀彩票代理BENWENJIANGBANGZHUWOMENZHUIZONGDINGWEIUnityYOUXIYUNXINGHUANMAN,KADUNDEWENTI。RUGUOWOMENDEYOUXICUNZAIQITAWENTI,RUYOUXIBENGKUIHUOZHEYOUXIDETUXINGBIAOXIANBURUYUQISUOXIANG,NEIMEZHEIPIANWENZHANGKENENGBUHUIYOUSHENMEBANGZHU。RUGUOYOUXICUNZAIDEWENTIBUZAIBENWENTAOLUNFANWEINEI,QINGCHANGSHIZAIUnity Manual, Unity Forums or Unity AnswersXUNQIUDAAN。

    如果我们还不熟悉Profiler Window的使用,请先阅读Unity性能优化(1)-官方文档简译

     

    关于游戏性能的概要介绍

    帧率Frame rate是衡量游戏性能的基本指标。在游戏中,一帧类似于动画中的一帧,它是我们游戏绘制到屏幕上的一个静止画面。绘制一帧到屏幕上叫做渲染一帧。帧率,或者说帧被渲染的有多快,用FPS衡量(frames per second)。

    荣耀彩票代理DADUOSHUDANGQIANYOUXIDEMUBIAOSHIZHENLV60FPS。TONGCHANGLAISHUO,ZHENLVZAI30FPSYISHANGSHIKEYIJIESHOUDE,TEBIESHIDUIYUBUXUYAOKUAISUFANYINGHUDONGDEYOUXI,LIRUXIUXIANJIEMIMAOXIANYOUXIDENG。YOUXIEXIANGMUYOUTESHUDEXUQIU,ZAIVRYOUXIZHONG,ZEZHISHAOXUYAO90FPS。DANGZHENLVJIANGDIDAO30FPSYIXIASHI,TONGCHANGWANJIAHUIYOUBUHAODETIYAN;TUXINGKENENGBUWENDINGBINGQIEGANJUECAOZUOFANKUIBUJISHI。JINGUANRUCI,ZHONGYAODEBUJINJINSHISUDU,ZHENLVBIXUYEFEICHANGWENDING。WANJIATONGCHANGDUIZHENLVDEBIANHUABIJIAOMINGAN,BUWENDINGDEZHENLVTONGCHANGBIDIYIXIEDANSHIHENWENDINGDEZHENLVBIAOXIANGENGCHA。

    SUIRANZHENLVSHIYIGEWOMENTANLUNYOUXIXINGNENGDEJIBENBIAOZHUN,DANSHIDANGWOMENCHANGSHIYOUHUAWOMENDEYOUXIXINGNENGSHI,DUIYUWOMENLAISHUOGENGYOUYONGDESHIXUANRANYIZHENXUYAODUOSHAOHAOMIAO。ZHEIYOULIANGGEYUANYIN。SHOUXIAN,ZHEISHIYIGEGENGJINGQUEDEDULIANG。DANGWOMENCHANGSHIYOUHUAXINGNENGSHI,MEIYIHAOMIAOJISUANYOUZHUYUWOMENDEMUBIAO。DIER,ZHENLVDEXIANGDUIGAIBIANZAIBUTONGFANWEIYIWEIZHEBUTONGDEBIANHUA。CONG60DAO50FPSCHENGXIANCHUDESHIEWAI3.3HAOMIAODEYUNXINGSHIJIAN,DANSHICONG30DAO20FPSCHENGXIANCHUDESHIEWAIDE16.6HAOMIAODEYUNXINGSHIJIAN。ZAIZHEIGELIZIZHONG,TONGYANGSHIJIANGDILE10FPS,DANSHIXUANRANYIZHENSHANGSHIJIANDECHABIESHIHENXIANZHUDE。

    荣耀彩票代理ZHENLVDUIYUWOMENLAISHUOKEYIYONGYULIJIEWEIXUANRANYIZHENBIXUYONGDUOSHAOHAOMIAOYINEIWANCHENG。TONGGUOGONGSHI 1000/XIANGYAODADAODEZHENLV。TONGGUOZHEIGEGONGSHIKEYIDEDAO,YOUXIYAOMEIMIAOXUANRAN30ZHEN(30FPS),NEIMEBIXUZAI33.3HAOMIAOZHINEIXUANRANWANMEIYIZHEN。YIGE60FPSYUNXINGDEYOUXI,BIXUZAI16.6HAOMIAONEIXUANRANWANMEIYIZHEN。

    YAOXUANRANMEIYIZHEN,UnityBIXUZHIXINGHENDUOBUTONGDERENWU。JIANDANDESHUO,UnityBIXUGENGXINYOUXIDEZHUANGTAI,HUOQUYOUXIDEKUAIZHAOBINGQIEBAKUAIZHAOHUADAOPINGMUSHANG。YOUYIXIERENWUSHIZAIMEIYIZHENDOUZHIXINGDE,BAOKUODUQUYONGHUSHURU,ZHIXINGJIAOBEN,YUNXINGGUANGZHAOJISUANDENG。CHUCIZHIWAI,YOUXUDUOCAOZUOSHIZAIYIZHENZHIXINGDUOCIDE,LIRUWULIYUNSUAN。DANGSUOYOUZHEIXIERENWUDOUZHIXINGDEZUGOUKUAISHI,WOMENDEYOUXICAIHUIYOUWENDINGQIEKEJIESHOUDEZHENLV。DANGZHEIXIERENWUZHIXINGDEBUGOUKUAISHI,XUANRANYIZHENJIANGHUAFEITAIZHANGDESHIJIAN,BINGQIEZHENLVHUIYINCIXIAJIANG。

    荣耀彩票代理ZHIDAONAXIERENWUHUAFEILETAIZHANGDESHIJIANZHIXING,DUIYUWOMENZHIDAOZENYANGQUJIEJUEXINGNENGWENTISHISHIFENGUANJIANDE。YIDANWOMENZHIDAOLENAXIERENWUJIANGDILEZHENLV,WOMENJIUKEYICHANGSHIQUYOUHUAYOUXIDENEIYIBUFEN。ZHEIJIUSHIWEISHENMEXINGNENGFENXIGONGJUZHEIMEGUANJIAN:XINGNENGFENXIGONGJUGAOSUWOMENZAIYIZHENZHONGMEIGERENWUHUAFEILEDUOZHANGSHIJIAN。

     

    录制分析数据

    为了调查性能问题,我们必须首先从我们游戏性能差的部分录制分析数据。为了精确的录制分析数据,我们必须生成一个development build版本的游戏,并且当游戏在目标硬件上运行时进行分析。

    如果还不熟悉怎么生成development build版本的游戏,并在目标硬件上运行时进行分析,请查看这篇文章Unity性能优化(1)-官方文档简译

     

     

    从我们游戏的development build录制数据

    如果还不熟悉怎么生成development build版本的游戏,并在目标硬件上运行时进行分析,请查看这篇文章Unity性能优化(1)-官方文档简译

    -ZAIMUBIAOSHEBEISHANGSHENGCHENGdevelopment build。

    -DANGWOMENDEYOUXIYUNXINGDAOXINGNENGCHUXIANWENTIDEBUFENSHIKAISHILUZHIFENXI。

    荣耀彩票代理-YIDANWOMENLUZHIDESHUJUBAOHANLEXINGNENGWENTIDEYANGBENSHI,DIANJIProfilerCHUANGKOUSHANGBUDERENYIWEIZHIZANTINGYOUXI,BINGQIEXUANZEYIZHEN。

    荣耀彩票代理-ZAICHUANGKOUSHANGBANBUFEN,XUANZEZHANSHICHUXINGNENGWENTIDENEIYIZHEN。ZHEIKENENGSHITURANDEDIZHENSHU,YEKENENGJINJINSHICHIXUDEPINGCHANGDEZHENSHU,ZHISHIBIWOMENXIWANGDEZHENSHUDI。WOMENKEYISHIYONGJIANPANDEZUOYOUJIANTOUANJIANHUOZHEProfilerSHANGBUKONGZHILANDEQIANHOUANNIUYIDONGZHEN,GENGHAODEKONGZHIXUANZEZHEN。

    description

    WOMENYIJINGSHOUJIDAOLEYOUXIXINGNENGBUHAODEBUFENDEXINGNENGSHUJU,JIEXIALAIRANGWOMENXUEXIZENMEQUFENXIZHEIXIESHUJU。

    分析性能数据

    荣耀彩票代理ZAIWOMENDEDAOYINQIYOUXIXINGNENGWENTIDEYUANYINZHIQIAN,WOMENBIXUXIANXUEXIZENMEYANGQUFENXIXIANSHIZAIProfilerCHUANGKOUSHANGDEXINGNENGSHUJU。WOMENZHIDAO,DANGUnityWUFAJISHIDEWANCHENGXUANRANYIZHENSUOXUDEQUANBURENWUSHI,HUIFASHENGZHENLVDEXIAJIANG。WOMENKEYIZAIProfilerCHUANGKOUZHONGKANDAONAXIERENWUZHENGZAIZHIXING,ZHIXINGRENWUHUAFEIDESHIJIAN,YIJIRENWUZHIXINGDESHUNXU。ZHEIXIEXINXIJIANGBANGZHUWOMENLIJIE,YOUXIDENABUFENZAIXUANRANZHENSHIHUAFEILETAIZHANGDESHIJIAN。

    最好是实践使用Profiler,比尝试去按照精确的顺序学习要好的多。我们能够自己理解数据的意义是很有用的,这样当我们遇到新问题时就可以自己调查。或者仅仅是知道在Unity Answers上怎么查找,也是一个好的开始。

    荣耀彩票代理WEILEXUEXIZENMEQUFENXIXINGNENG,WOMENJIANGSHIYONGCPU usage profilerZUOWEILIZI。DANGWOMENDIAOCHAZHENLVWENTISHI,ZHEIGEKENENGSHIWOMENSHIYONGDEZUIDUODEProfilerLE。

    The CPU usage profiler

    DANGWOMENCHAKANProfilerCHUANGKOUDESHANGBUSHI,KEYIKANDAOWANCHENGMEIZHENDERENWUHUAFEILEDUOSHAOcpuSHIJIAN。

    description

    WOMENKEYIKANJIANHUAFEIDESHIJIANYONGYANSEBIAOCHULEFENLEI。BUTONGDEYANSEBIAOSHIZAIXUANRANCAOZUOSHANGHUAFEIDESHIJIAN,WULIYUNSUANHUAFEIDESHIJIANDENGDENG。ProfilerZUOCEBIAOMINGLENAZHONGYANSEDAIBIAONALEIRENWU。

    荣耀彩票代理TONGGUOXIAMIANDEJIETUWOMENKEYIKANCHU,ZHEIZHENZHONGZHUYAODESHIJIANHUAFEIZAIXUANRANCAOZUOSHANG。ZAICHUANGKOUDIBUXIANSHILEZHEIZHENZHONGSUOYOUDEcpuSHIJIANGONGXIAOHAO85.95HAOMIAO。

    description

     

    层级视图The Hierarchy view

    荣耀彩票代理WOMENSHIYONGCENGJISHITUQUWAJUEGENGSHENRUDEXINXI,KANKANZAIZHEIZHENZHONGDAODISHINAXIERENWUHUAFEILEZUIDUODEcpuSHIJIAN。DANGWOMENXUANZHONGCPU usage profilerSHI,ZHEIYIZHENDEXIANGXIXINXIHUIXIANSHIZAIProfilerCHUANGKOUDEXIABU。WOMENKEYIZAIProfilerDEZUOXIADEXIALACAIDANZHONGXUANZECENGJISHITU,ZHEIKEYISHIWOMENCHAKANcpuRENWUDEXIANGXIXINXI。

    description

    层级视图中,可以点击任意的列标题,按照这列信息的值来列排序。例如,点击Time ms可以按照函数花费时间排序,点击Calls可以按照当前选中帧中函数的执行次数排序。在上面的截图中,我们按照时间排序,可以看到Camera.Render荣耀彩票代理花费了最多的cpu时间。

    如果一个函数的名字左边有箭头,则可以点击展开,查看这个函数调用了哪些其他函数,并且这些函数是怎样影响性能的。Self ms表示函数自身的花费时间,Time ms表示这个函数以及它所调用的其他函数的总时间。

    description

    在这个例子中,我们可以看到,在Camera.Render,最多的消耗和Shadows.RenderJob函数相关。即使我们对这个函数还不太了解,我们也已经对性能问题有了很多信息了。我们知道了问题是和渲染相关的,并且最昂贵的任务是需要处理阴影。

    ZAICENGJISHITUZHONG,LINGYIGEHAOCHUSHIWOMENKEYIBIJIAOYOUXIZHONGDEMEIYIZHEN,ZHEIYANGWOMENJIUKEYILIJIEXINGNENGSHIZENYANGSUIZHESHIJIANBIANHUADE。SHIYONGCPU usage profiler,WOMENKEYIGENZONGYIGEHANSHUCONGZHENDAOZHENDEcpuXIAOHAO。DANGWOMENZAICENGJISHITUZHONGDIANJIHANSHUMINGZISHI,CPU usage profilerJIANGZAIProfilerCHUANGKOUSHANGBUDETUXINGSHITUZHONGGAOLIANGXIANSHIZHEIGEHANSHUDEXINXI。

    description

    举个例子,如果在层级视图中点击了Gfx.WaitForPresent,则和Gfx.WaitForPresent直接相关的渲染数据将会在Profiler的图形展示中高亮显示。

    时间线视图The Timeline view

    荣耀彩票代理XIANZAIWOMENSHIYONGSHIJIANXIANSHITULAIXUEXIGENGDUOGUANYUWOMENDEXUANRANWENTIDEXINXI。SHIJIANXIANSHITUXIANSHILELIANGJIANSHI:cpuRENWUDEZHIXINGSHUNXUHENEIGEXIANCHENGFUZENAXIERENWU。WOMENKEYIProfilerDEZUOXIADEXIALACAIDANZHONGXUANZESHIJIANXIANSHITU(HEXUANZECENGJISHITUWEIZHIXIANGTONG)。

    description

    线程允许不同的任务同时执行。当一个线程执行一个任务时,另外的线程可以执行另一个完全不同的任务。和Unity的渲染过程相关的线程有三种:主线程,渲染线程和工人线程(worker threads荣耀彩票代理)。了解哪个线程负责哪些任务是很有用处的:一旦我们知道了在哪个线程上的任务执行的最慢,那么我们就应该集中努力优化在那个线程上的操作。

    description

    我们可以缩放时间线视图,来更仔细的查看单独的任务。被调用的函数会显示在调用他的函数的下面。在这个例子中,我们已经放大了去看组成Shadows.RenderJob任务的其他独立任务。我们看到Shadows.RenderJob调用的函数发生在主线程,也可以看到工人线程执行和阴影相关的任务。主线程的一个任务WaitingForJob指示出主线程正在等待工人线程完成任务。从这里,我们可以推断出和阴影相关的渲染操作,在主线程和工人线程,花费了太多的时间。现在和问题相关的信息我们已经了解很多了。

    其他的Profiler

    荣耀彩票代理DANGZHUIZONGZHENLVXIANGGUANDEXINGNENGWENTISHI,JINGUANCPU usage profilerSHIZUICHANGYONGDEProfiler,DANSHIQITADEProfilerYESHISHIFENYOUYONGDE。SHUXITAMENTIGONGDEXINXISHIHENHAODEZHUYI。

    荣耀彩票代理QINGCHANGSHIANZHAOSHANGMIANDEBUZHOUSHIYONGQITADEProfiler,SHIYONGBUTONGDESHITU,XUEXITAMENMEIZHENTIGONGDEXINXI。LIRU,CHANGSHISHIYONGXUANRANProfilerCHAKANXUANRANSHUJUSHIZENMEZHUZHENBIANHUADE。

    确定性能问题的原因

    XIANZAIWOMENYIJINGSHUXIZENMEZAIProfilerCHUANGKOUZHONGDUQUHEFENXIXINGNENGSHUJULE,WOMENKEYIKAISHICHAZHAOYINQIXINGNENGWENTIDEYUANYINLE。

    排除垂直同步的影响

    荣耀彩票代理CHUIZHITONGBU(VSync)YONGLAITONGBUYOUXIDEZHENLVHEPINGMUDESHUAXINLV。CHUIZHITONGBUHUIYINGXIANGYOUXIDEZHENLV,ZAIProfilerCHUANGKOUZHONGKEYIKANDAOYINGXIANG。RUGUOWOMENBUSHITEBIEQUEDINGWENTISUOZAI,CHUIZHITONGBUDEYINGXIANGKENENGKANQILAIXIANGXINGNENGWENTI,SUOYI,ZAIJIXUCHAZHAOWENTIZHIQIAN,YINGGAIXUEXIZENMEPAICHUCHUIZHITONGBUDEYINGXIANG。

    在CPU usage profiler中隐藏垂直同步信息

    WOMENKEYIXUANZEYAOZAICPU usage profilerZHONGYINZANGDEXINXI,ZHEIYUNXUWOMENHEHULVEDANGQIANWENTIWUGUANDEXINXI。

    荣耀彩票代理ANRUXIABUZHOUZAICPU usage profilerZHONGYINZANGCHUIZHITONGBUXINXI:

    -XUANZHONGCPU usage profiler。

    -ZAICPU usage profilerCHUANGKOUZHONGZUOCEDIANJIHUANGSEDEFANGKUANG,BIAOJIZHECHUIZHITONGBU,JIUKEYIYINZANGXINXI。

    不理会层级视图中的垂直同步信息

    ZAICPU usage profileDECENGJISHITUZHONGWUFAYINZANGCHUIZHITONGBUXINXI,DANSHIWOMENKEYIXUEXITABIAOXIANCHUSHENMEYANGZI,ZHEIYANGWOMENJIUNENGBULIHUITA。

    当我们在层级视图中看见一个名为WaitForTargetFPS的函数时,这意味着我们的游戏在等待着垂直同步,我们无须调查这个函数,并安全的忽略他。

    关闭垂直同步

    垂直同步不是在所有的平台都可以关闭,许多平台(例如iOS)是强制开启的。当我们在不强制开启垂直同步的平开上开发时,当我们分析性能时,可以为整个项目关闭垂直同步。通过菜单Edit **> **Project Settings >Quality打开质量设置,在VSync Count的下拉菜单中选择Don’t Sync。

    description

    分析渲染

    XUANRANSHICHANGJIANDEYINQIXINGNENGWENTIDEYUANYIN。DANGWOMENCHANGSHIXIUFUYIGEXUANRANXINGNENGWENTIZHIQIAN,HENZHONGYAODESHIQUERENWOMENDEYOUXISHICPUSHOUXIANHAISHIGPUSHOUXIAN,YINWEITAMENXUYAOYONGBUTONGDEFANGFAQUJIEJUE。

    JIANDANDESHUO,CPUFUZEJUEDINGSHENMEDONGXIXUYAOBEIXUANRAN,ERGPUFUZEXUANRANTA。DANGXUANRANXINGNENGWENTISHIYINWEICPUHUAFEILETAIZHANGSHIJIANQUXUANRANYIZHENSHI,SHICPUSHOUXIAN。DANGXUANRANXINGNENGWENTISHIYINWEIGPUHUAFEILETAIZHANGSHIJIANQUXUANRANYIZHENSHI,SHIGPUSHOUXIAN。

    识别游戏是否是GPU受限

    SHIBIESHIFOUSHIGPUSHOUXIANDEZUIKUAIDEFANGFASHISHIYONGGPU usage profiler。BUXINGDESHI,BINGBUSHISUOYOUDESHEBEIHEQUDONGDOUZHICHIZHEIGEProfiler。ZAIPANDUANSHIFOUSHIGPUSHOUXIANQIAN,WOMENXUYAOXIANJIANCHAGPU usage profilerZAIWOMENYOUXIDEMUBIAOSHEBEISHANGSHIFOUKEYONG。

    JIANCHAGPU usage profilerSHIFOUKEYONG,ZUNXUNXIAMIANDEBUZHOU:

    -在Profiler窗口的左上角点击Add profiler。

    荣耀彩票代理-ZAIXIALACAIDANZHONGXUANZEGPU。

    RUGUOMUBIAOSHEBEIBUZHICHI,WOMENKEYIKANDAOYOUCEXIANSHIXINXI“BUZHICHIGPUFENXI”。

    description

    RUGUOMEIYOUKANDAOZHEIGEXINXI,YIWEIZHEGPU usage profilerZHICHIWOMENDEMUBIAOSHEBEI。ZAIWOMENDELIZIZHONG,RUGUOGPU usage profilerKEYONG,ZEKEYIANZHAORUXIABUZHOUKUAISUJIANDANDEQUEDINGYOUXISHIFOUSHIGPUSHOUXIAN。

    -XUANZHONGGPU usage profiler。

    荣耀彩票代理-CHAKANQUYUXIAFANGZHONGJIANBUFENDEcpuSHIJIANHEgpuSHIJIAN,ZHEILIXIANSHIDESHIDANGQIANXUANZEDEZHENDEXINXI。

    RUGUOGPUSHIJIANDAYUCPUSHIJIAN,WOMENKEYIQUEDINGZAIYOUXIYUNXINGDEZHEIYIZHENZHONGSHIGPUSHOUXIAN。

    description

    RUGUOGPU usage profilerBUKEYONG,WOMENRENGRANYOUBANFAQUERENYOUXISHIFOUSHIGPUSHOUXIAN。WOMENKEYITONGGUOCPUZHANYONGQUQUEREN。RUGUOWOMENKANDAOCPUZAIDENGDAIGPUWANCHENGRENWU,NEIMEYIWEIZHEGPUSHOUXIAN。WOMENKEYITONGGUOYIXIABUZHOU:

    -XUANZECPU usage profiler。

    -ZAICHUANGKOUXIABUCHAKANXUANZEZHENDEXIANGXIXINXI。

    -XUANZECENGJISHITU

    -选择按Time ms列排序

    如果函数Gfx.WaitForPresent在CPU usage profiler中消耗的时间最长,这表明cpu在等待gpu。也就是说GPU受限。

    description

    解决GPU受限时的渲染问题

    如果我们已经确定了是GPU受限,那么请阅读this article学习解决方案。

    识别游戏是否是CPU受限

    荣耀彩票代理RUGUODAOZHEILIHAIMEIYOUSHIBIECHUYOUXIXINGNENGWENTIDEYUANYIN,RANGWOMENXIANZAIDIAOCHAcpuXIANGGUANDEXUANRANWENTI。

    荣耀彩票代理-XUANZECPU usage profiler。

    -ZAIProfilerCHUANGKOUDESHANGBU,JIANCHADAIBIAOXUANRANDEYANSEDESHUJU。WOMENKEYIDIANJIYANSEFANGKUAIYINZANGHUOXIANSHIBUTONGZHONGLEIDEXINXI。

    ZAIMANDEZHENZHONG,RUGUOYIDABUFENSHIJIANDOUHUAFEIZAIXUANRANSHANG,NEIMEBIAOSHIXUANRANYINQILEWENTI。WOMENKEYIANZHAOXIAMIANDEBUZHOUJINYIBUWAJUEXINGNENGXINXI:

    -XUANZECPU usage profiler。

    -JIANCHACHUANGKOUXIAFANGXUANZHONGZHENDEXIANGXIXINXI。

    -XUANZECENGJISHITU。

    -点击Time ms荣耀彩票代理列,把函数按消耗时间排序。

    -DIANJILIEBIAOZHONGZUISHANGFANGDEHANSHU。

    荣耀彩票代理RUGUOXUANZHONGDEHANSHUSHIYIGEXUANRANHANSHU,NEIMECPU profilerHUIGAOLIANGXUANRANBUFEN。RUGUOSHIZHEIGEYUANYIN,NEIMEYIWEIZHESHIXUANRANXIANGGUANDECAOZUOYINQILEYOUXIDEXINGNENGBIAOXIAN,BINGQIEZAIZHEIYIZHENSHICPUSHOUXIANDE。ZHUYIHANSHUMINGHEHANSHUSHIZAINAGEXIANCHENGZHIXINGDE,ZHEIXIEXINXIDANGWOMENCHANGSHIXIUFUWENTISHISHIFENYOUYONG。

    解决CPU受限时的渲染问题

    如果我们已经确定了是CPU受限,那么请阅读this article学习解决方案。

    垃圾回收性能分析

    荣耀彩票代理JIEXIALAI,WOMENJIANCHASHIFOUSHILAJIHUISHOUYINQIDEXINGNENGPINGJING。LAJIHUISHOUSHIHEunityZIDONGNEICUNGUANLIXIANGGUANDEGONGNENG,ZHEIKENENGSHIYIGEMANDECAOZUO。

    -DIANJIXUANZECPU usage profiler

    -ZAIProfilerCHUANGKOU,CPU usage profilerZUOCE,KEYIDIANJIYOUYANSEDEXIAFANGKUAI,KONGZHIXIANSHIHUOZHEYINZANGXIANGGUANDEXINXI,YEKEYITUODONGTA,ANZHAOZIJIDEYIYUANPAIXU。ZAIXIAMIANDEJIETUZHONG,WOMENYINZANGLELAJIHUISHOUQIYIWAIDESUOYOUQITAXINXI,BINGQIEBALAJIHUISHOUQITUODONGDAOLEZUISHANGFANG。

    description

    荣耀彩票代理RUGUOZAIYIGEMANDEZHENZHONG,YIDABUFENSHIJIANBEILAJIHUISHOUXIAOHAO,ZHEIZHISHIZHEWOMENKENENGCUNZAIZHELAJIHUISHOUGUODUODEWENTI。WOMENKEYIGENGJIASHENRUDEFENXISHUJULAIQUEREN。

    -XUANZHONGCPU usage profiler,CHAKANXIAFANGCHUANGKOUXIANSHIDEGUANYUDANGQIANXUANZHONGZHENDEXIANGXIXINXI。

    -XUANZECENGJISHITU

    -选择按照Time ms排序

    如果函数GC.Collect()出现在最上方,并且花费了过多的cpu时间,那么我们可以确认垃圾回收是我们游戏的问题所在。

    解决垃圾回收问题

    如果我们确定了游戏存在垃圾回收的问题,请阅读this article学习解决方案。

    物理性能分析

    荣耀彩票代理DAOCIWEIZHI,RUGUOWOMENPAICHULEXUANRANWENTIHELAJIHUISHOUWENTI,NEIMERANGWOMENCHAKANFUZADEWULIYUNSUANSHIBUSHIWENTISUOZAI。

    荣耀彩票代理-DIANJIXUANZECPU Usage profiler

    -ZAIProfilerCHUANGKOU,CPU usage profilerZUOCE,KEYIDIANJIYOUYANSEDEXIAFANGKUAI,KONGZHIXIANSHIHUOZHEYINZANGXIANGGUANDEXINXI,WOMENGUANZHUWULIXINXI(CHENGSE)

    荣耀彩票代理RUGUOZAIYIGEMANDEZHENZHONG,YIDABUFENSHIJIANBEIWULIYUNSUANXIAOHAO,ZHEIZHISHIZHEWULIYUNSUANKENENGYINQILEXINGNENGWENTI。WOMENKEYIGENGJIASHENRUDEFENXISHUJULAIQUEREN。

    -XUANZHONGCPU usage profiler,CHAKANXIAFANGCHUANGKOUXIANSHIDEGUANYUDANGQIANXUANZHONGZHENDEXIANGXIXINXI。

    -XUANZECENGJISHITU

    -选择按照Time ms排序

    荣耀彩票代理-DIANJIXINXILIEBIAODEZUISHANGFANG,BINGXUANZHONG

    RUGUOSHIWULIHANSHU,NEIMEZAIProfilerSHANGFANGHUIGAOLIANGWULIYUNSUANDEBUFEN。RUGUOSHIZHEIZHONGQINGKUANG,SHUOMINGYOUXIDEXINGNENGWENTISHIHEWULIYUNSUANXIANGGUANDE。

    解决物理问题

    RUGUOQUEDINGLEXINGNENGWENTISHIWULIYUNSUANYINQIDE,NEIMEXIAMIANJIGEZIYUANJIANGYOUZHUYUJIEJUEWENTI:

    -This page of the Unity Manual,荣耀彩票代理虽然是写给iOS开发者的,但是其中一些物理优化的提示是对所有Unity游戏都适用的。

    -This tutorial on optimising physics in a Unity game,包含一些有帮助的提示。

    -Unite 2012 talk on optimization中讲物理的一节,包含了一些常见的物理问题的有用的总结。

    脚本运行慢的问题

    XIANZAIRANGWOMENJIANCHA,MANHUOZHEGUOYUFUZADEJIAOBENSHIFOUSHIYINQIXINGNENGWENTIDEYUANYIN。JIAOBEN,ZAIZHEILI,ZHIDESHIFEIUnityYINQINGDEDAIMA。ZHEITONGCHANGYIWEIZHEWOMENZIJIXIEDEJIAOBEN,HUOZHESHIYIXIEWOMENZAIXIANGMUZHONGSHIYONGDECHAJIANDEDAIMA。

    -DIANJIXUANZECPU Usage profiler

    -ZAIProfilerCHUANGKOU,CPU usage profilerZUOCE,KEYIDIANJIYOUYANSEDEXIAFANGKUAI,KONGZHIXIANSHIHUOZHEYINZANGXIANGGUANDEXINXI,WOMENGUANZHUJIAOBENXINXI

    RUGUOZAIYIGEMANDEZHENZHONG,YIDABUFENSHIJIANBEIJIAOBENYUNXINGXIAOHAO,ZHEIZHISHIZHEZHEIXIEMANDEYONGHUJIAOBENKENENGYINQILEXINGNENGWENTI。WOMENKEYIGENGJIASHENRUDEFENXISHUJULAIQUEREN。

    -XUANZHONGCPU usage profiler,CHAKANXIAFANGCHUANGKOUXIANSHIDEGUANYUDANGQIANXUANZHONGZHENDEXIANGXIXINXI。

    -XUANZECENGJISHITU

    -选择按照Time ms排序

    荣耀彩票代理-DIANJIXINXILIEBIAODEZUISHANGFANG,BINGXUANZHONG

    RUGUOSHIYONGHUJIAOBENDEHANSHU,NEIMEZAIProfilerSHANGFANGHUIGAOLIANGJIAOBENDEBUFEN。RUGUOSHIZHEIZHONGQINGKUANG,SHUOMINGYOUXIDEXINGNENGWENTISHIHEYONGHUJIAOBENXIANGGUANDE。

    请注意,这里有一个意外情况:如果我们游戏包含和渲染相关的代码,例如屏幕后期效果脚本或者OnWillRenderObject 或者 OnPreCull函数中的代码,Profiler上方可能会高亮渲染数据,而不是脚本数据。

    荣耀彩票代理JINGUANZHEIKENENGHUIZUICHUHUIZAOCHENGYIDIANKUNHUO,DANSHIZAICENGJISHITUHESHIJIANXIANSHITUZHONG,TONGCHANGWOMENKEYIZHUIZONGDAOFUZERENDEDAIMA。

    解决脚本慢的问题

    RUGUOWOMENQUERENLESHIJIAOBENYINQIDEXINGNENGWENTI,ZHEILIYOUYIXIEKEYIGAIJINXINGNENGDEJIQIAO,TUIJIANJIGEJIAOBENYOUHUADEZIYUANRUXIA:

    -This page in the Unity Manual 聚焦移动平台的脚本优化,但是其中的建议对所有的开发者都是有用的。

    -This page in the Unity Manual 荣耀彩票代理包含了一些如何在用户脚本中避免昂贵的函数调用的建议。

    -Unite 2012 talk on optimization荣耀彩票代理 包含一些常见脚本问题的有用的总结。

    其他引起性能问题的原因

    荣耀彩票代理JINGUANWOMENYIJINGTAOLUNLESIZHONGZUICHANGJIANDEYINQIXINGNENGWENTIDEYUANYIN,WOMENDEYOUXIRENGRANYOUKENENGYUDAOHEZHEIXIEFANGMIANBUXIANGGUANDEWENTI。RUGUOSHIZHEIZHONGQINGKUANG,WOMENYINGGAIZUNXUNSHANGMIANDEFANGFAJIEJUEWENTI:SHOUJISHUJU,SHIYONGCPU usage profilerDIAOCHAXINXI,ZHAODAOYINQIWENTIDEHANSHU。YIDANWOMENZHIDAOLEYINQIWENTIHANSHUDEMINGZI,WOMENKEYIZAIUnity Manual, Unity Forums or Unity AnswersZHONGCHAZHAOHANSHUDEXIANGGUANXINXI,ZHEIYEXUHUIJIESHENGNINHUAFEIDESHIJIAN。

     

About IT165 - 广告服务 - 隐私声明 - 版权申明 - 免责条款 - 网站地图 - 网友投稿 - 联系方式
本站内容来自于互联网,仅供用于网络技术学习,学习中请遵循相关法律法规