标签:ide public lap com indicator bsp rac 生成器 mon
每个对象做大范围正弦移动,创建1000-5000个对象,保证场景分割树的实时更新,并测试帧率
移动脚本:
using UnityEngine; using System.Collections; public class Test1 : MonoBehaviour { public Rigidbody rigidbodyObj; void Update() { switch (Random.Range(0, 3)) { case 0: transform.position = Vector3.forward * Mathf.Sin(Time.time * 180) * 180; //rigidbodyObj.position = Vector3.forward * Mathf.Sin(Time.time * 180) * 180; break; case 1: transform.position = Vector3.left * Mathf.Sin(Time.time * 180) * 180; //rigidbodyObj.position = Vector3.left * Mathf.Sin(Time.time * 180) * 180; break; case 2: transform.position = Vector3.right * Mathf.Sin(Time.time * 180) * 180; //rigidbodyObj.position = Vector3.right * Mathf.Sin(Time.time * 180) * 180; break; } } }
生成器脚本:
using UnityEngine; using System.Collections; public class Test2 : MonoBehaviour { public int count = 10000; public GameObject template; void Awake() { for (int i = 0; i < count; i++) { var go = Instantiate(template); go.transform.position = Random.insideUnitSphere * 10f; } } }
i5的配置下
500个动力学打开的刚体Collider已经小于20fps,使用Rigidbody.position移动和使用Transform.position移动差别不大。而且500个打开了重力的刚体Collider仅有3fps
1万个非刚体Collider可以达到30-35fps,并且和是否开关Trigger无关。由于非刚体Collider是被动触发,我还测试了下没有Collider的情况,似乎帧率是快了1-2fps并且相对稳定,也可能是错觉。
标签:ide public lap com indicator bsp rac 生成器 mon
原文地址:http://www.cnblogs.com/hont/p/6034790.html