Unity 琐碎(4) 可视化辅助调试Giamos
可以在代码中绘制一些输出结果或者中间输出内容,比如计算后的包围盒等等
类变量
方法 | 作用 |
---|---|
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.
当然结果只能在Scene视图中查看
测试
比如我们要绘制一个输出的包围盒
private Bounds needDraw ;
void OnDrawGizmos()
{
Gizmos.color = new Color(1, 0, 1, 0.5F);
Gizmos.DrawWireCube(needDraw.center, needDraw.size);
}