- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
unity3D技术之PerformanceOptimization性能优化unity3D技术之PerformanceOptimization性能优化
1. Use Static Typing使用静态类型When using JavaScript the most important optimization is to use static typing instead of dynamic typing. Unity uses a technique called type inference to automatically convert JavaScript constructs to statically typed code without you having to do any work.使用JavaScript很重要的优化是使用静态类型替代动态类型。Unity使用一种叫做类型推理的技术来自动转换JavaScript为静态类型而无需你做任何工作。【狗刨学习网】C# JavaScript using UnityEngine;using System.Collections;public class example : MonoBehaviour {public int foo = 5;}var foo = 5;In the above example foo will automatically be inferred to be an integer value. Thus Unity can apply a lot of compile time optimizations, without costly dynamic name variable lookups etc. This is one of the reasons why Unitys JavaScript is on average around 20 times faster than other JavaScript implementations. 上面例子中的foo将自动推断为一个整数值。因此Unity能节约大量时间,而不使用动态名称变量查找等耗时的计算。这就是为什么Unity的执行平均速度比其他JavaScript快20倍的原因之一。The only problem is that sometimes not everything can be type inferred, thus Unity will fall back to dynamic typing for those variables. By falling back to dynamic typing, writing JavaScript code is simpler. However it also makes the code run slower. 唯一的问题是,有时不是所有的东西都能被类型推断,因此Unity会对这些变量重新使用动态类型.通过这样,书写JavaScript代码会很简单。不过他也使代码执行变慢。Lets see some examples.我们来看一些例子.C# JavaScript using UnityEngine;using System.Collections;public class example : MonoBehaviour {void Start() {duck foo = GetComponentMyScript();foo.DoSomething();}}function Start () {var foo = GetComponent(MyScript);foo.DoSomething();}Here foo will be dynamically typed, thus calling the function DoSomething takes longer than necessary - because the type of foo is unknown, it has to figure out whether it supports DoSomething function, and if it does, invoke that function. 这里foo将是动态类型,因此调用函数DoSomething必须要更长时间 – 因为foo的类型未知,它必须弄明白是否支持DoSomething函数,如果支持,就调用那个函数。C# JavaScript using UnityEngine;using System.Collections;public class example : MonoBehaviour {void Start() {MyScript foo = GetComponentMyScript();foo.DoSomething();}}f
您可能关注的文档
最近下载
- 平陆运河建设对区域经济影响的研究.docx VIP
- 2023年辽宁省大连市中考一模语文试题(含答案).pdf VIP
- 4.2 中国的工业-2023-2024学年八年级地理上册同步精品课件(湘教版).pptx VIP
- 粉色插画风医院感染基础知识培训PPT模板.pptx VIP
- 西宁市2024-2025学年九年级上学期语文期末测试试卷.doc VIP
- 湘教版八年级上册第四章中国的主要产业+第二节工业 (共18张PPT).pptx VIP
- 高品质ppt模板▏院感手卫生知识培训课件.pptx VIP
- 学堂在线兵棋期末考试答案.docx VIP
- 网络安全等级保护-重大风险隐患项描述实践指南(【2025】测评报告新增).docx VIP
- 八上第四单元--经济与文化---第3课--工业的分布-(第2课时).doc VIP
原创力文档


文档评论(0)