Unity 瑣碎(4) 可視化輔助調試Giamos

Gizmos 類html

能夠在代碼中繪製一些輸出結果或者中間輸出內容,好比計算後的包圍盒等等測試

類變量

方法 做用
color 控制輸出顏色
matrix Set the gizmo matrix used to draw all gizmos.
DrawCube 繪製立方體
DrawWireCube 線框立方體
DrawLine 繪製直線
DrawMesh 繪製Mesh
DrawWireMesh 線框Mesh
DrawRay 方向射線
DrawSphere
DrawWireSphere

繪製方式

All gizmo drawing has to be done in either OnDrawGizmos or OnDrawGizmosSelected functions of the script.3d

固然結果只能在Scene視圖中查看
markcode

測試

好比咱們要繪製一個輸出的包圍盒htm

private Bounds needDraw ;
void OnDrawGizmos() 
{
    Gizmos.color = new Color(1, 0, 1, 0.5F);
    Gizmos.DrawWireCube(needDraw.center, needDraw.size);
}
相關文章
相關標籤/搜索