Unity3D - 关于Static静态对象

来源:互联网 发布:双氧水流量计优化 编辑:程序博客网 时间:2024/05/06 17:26

在官方文档中的描述:


许多的优化需要知道一个对象可以移动的游戏中。关于静态信息(IE,非移动)对象往往可以预先计算在知识的编辑器,它将不受物体的位置变化无效。例如,渲染可以通过组合几个静态对象到一个单一的,大的对象被称为一个批处理。

一个游戏对象检查员在最右一个静态的复选框和菜单,这是用来在统一中,物体不会移动各种不同系统的通知。对象可以被标记为静态的这些系统中的每一个单独的,所以你可以选择不计算对象的静态优化,当它不利于。

静态设置

所有的一切,没有启用或禁用静态状态,同时对所有系统使用它。这些系统是:

Lightmapping:提前对一个场景中的光照进行计算

Occluder and Occludee:基于特定的相机位置的物体渲染优化;

Batching:将若干个对象组合成一个更大的对象的渲染优化;

Navigation:使角色在场景中的障碍;

Off-mesh Links:在现场的不连续区域之间的导航系统的连接。

Reflection Probe:捕捉一个球形的视图,其周围的所有方向。

Static GameObjects


Many optimisations need to know if an object can move during gameplay. Information about a Static (ie, non-moving) object can often be precomputed in the editor in the knowledge that it will not be invalidated by a change in the object’s position. For example, rendering can be optimised by combining several static objects into a single, large object known as a batch.


The inspector for a GameObject has a Static checkbox and menu in the extreme top-right, which is used to inform various different systems in Unity that the object will not move. The object can be marked as static for each of these systems individually, so you can choose not to calculate static optimisations for an object when it isn’t advantageous.


Static Settings


The Everything and Nothing enable or disable static status simultaneously for all systems that make use of it. These systems are:


Lightmapping: advanced lighting for a scene;
Occluder and Occludee: rendering optimization based on the visibility of objects from specific camera positions;
Batching: rendering optimization that combines several objects into one larger object;
Navigation: the system that enables characters to negotiate obstacles in the scene;
Off-mesh Links: connections made by the Navigation system between discontinuous areas of the scene.
Reflection Probe: captures a spherical view of its surroundings in all directions.


See the pages about these topics for further details on how the static setting affects performance.


含有Collider和RigidBody的GameObject, Unity视之为Dynamic

含有Collider的GameObject, Unity视之为Static

 

如果Static的物体发生位移上的变化,Unity每一帧都会去重新缓存Static物体的Collider状态,这会消耗资源

 

所以只含有Collider的物体,就不要让他发生位置上的移动。或者给它加一个RigidBody的组件,把Gravity去掉,并且把IsKineMatic勾选上(该选项使得该物体不会因为其他物体的影响而发生物理上的改变)。


0 0