unity 在Game视图中显示Gizmos

自己画的Gizmos要想在Game视图中能看到,需要把Game视图窗口右上角的"Gizmos"按钮点下去。如图:

比如,下面代码以角色的capsuleCollider中心为中心画一个半径为0.8f的球体线框。

void OnDrawGizmos() {

        Vector3 capsuleColliderCenterInWorldSpace=GetComponent<CapsuleCollider> ().transform.TransformPoint (GetComponent<CapsuleCollider>().center);
        Gizmos.color = Color.yellow;
        Gizmos.DrawWireSphere (capsuleColliderCenterInWorldSpace,0.8f);
}

另外,如果在Scene视图中选中某个物体显示出其Gizmos,则切换到Game视图后只要将"Gizmos"按钮按下,则在Game视图下也能显示出此Gizmos。

参考:http://answers.unity3d.com/questions/224400/gismo-in-game-view.html

原文地址:https://www.cnblogs.com/wantnon/p/4379487.html