Unity3D - 關於Static靜態對象

在官方文檔中的描述:


許多的優化需要知道一個對象可以移動的遊戲中。關於靜態信息(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勾選上(該選項使得該物體不會因爲其他物體的影響而發生物理上的改變)。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章