unity 在Game视图中显示Gizmos
时间:2015-03-31 00:24:24
收藏:0
阅读:1243
自己画的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);
}
参考:http://answers.unity3d.com/questions/224400/gismo-in-game-view.html
评论(0)