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
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!