共有回帖数 0 个
-
void Update()
{
Vector3 vector;
//Do other things
}
网上有Unity优化教程说最后把声明临时变量放在Update外面。
因为我某次看到官方视频里就是这么写代码的,所以我觉得这样写应该不会影响性能吧。
还有一段很基础的代码是这样的——
for(int i=0; i100000; i++)
{
int a=5;
//do other things
}
如果把int a=5放到for循环外面——
int a=5;
for(int i=0; i100000; i++)
{
//do other things
}
我测试出来的执行时间是几乎一样的。
求大神解答,怎么样算比较合理的编写代码方式,可以更高性能?
楼主 2015-07-21 21:29 回复
Copyright © 2010~2015 直线网 版权所有,All Rights Reserved.沪ICP备10039589号
意见反馈 |
关于直线 |
版权声明 |
会员须知