Unity Collider Bounds and extents 调试
using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class TestPhyCollider : MonoBehaviour { public Collider tree; public Vector3 scale = new Vector3(0.3f, 0.3f, 0.3f); public bool isExtent; public bool isSize; public void OnCollisionEnter(Collision other) { } public void OnDrawGizmos() { Gizmos.DrawCube(tree.bounds.center, scale); Gizmos.color = Color.blue; Gizmos.DrawCube(tree.bounds.max, scale); Gizmos.color = Color.yellow; Gizmos.DrawCube(tree.bounds.min, scale); if (isExtent) { Gizmos.color = Color.magenta; Gizmos.DrawCube(tree.bounds.center, tree.bounds.extents); } if (isSize) { Gizmos.color = Color.gray; Gizmos.DrawCube(tree.bounds.center, tree.bounds.size); } //下面一个点 var center = tree.bounds.center; center.y = tree.bounds.min.y; Gizmos.DrawCube(center, scale); //后面一个点 var center2 = tree.bounds.center; center2.z = tree.bounds.min.z; Gizmos.DrawCube(center2, scale); //前面一个点 var center3 = tree.bounds.center; center3.z = tree.bounds.max.z; Gizmos.DrawCube(center3, scale); //左边一个点 var center4 = tree.bounds.center; center4.x = tree.bounds.min.x; Gizmos.DrawCube(center4, scale); //右边一个点 var center5 = tree.bounds.center; center5.x = tree.bounds.max.x; Gizmos.DrawCube(center5, scale); } }
如果你感兴趣,你可以把你妹妹介绍给我