private BoxCollider mCollider;
    // Use this for initialization
    void Start ()
    {
        mCollider = GetComponent<BoxCollider> ();
        Bounds bounds = mCollider.bounds;

        Vector3 boundPoint1 = bounds.min;
        Vector3 boundPoint2 = bounds.max;
        Vector3 boundPoint3 = new Vector3 (boundPoint1.x, boundPoint1.y, boundPoint2.z);
        Vector3 boundPoint4 = new Vector3 (boundPoint1.x, boundPoint2.y, boundPoint1.z);
        Vector3 boundPoint5 = new Vector3 (boundPoint2.x, boundPoint1.y, boundPoint1.z);
        Vector3 boundPoint6 = new Vector3 (boundPoint1.x, boundPoint2.y, boundPoint2.z);
        Vector3 boundPoint7 = new Vector3 (boundPoint2.x, boundPoint1.y, boundPoint2.z);
        Vector3 boundPoint8 = new Vector3 (boundPoint2.x, boundPoint2.y, boundPoint1.z);
// rectangular cuboid
        // top of rectangular cuboid (6-2-8-4)
        Debug.DrawLine (boundPoint6, boundPoint2, Color.green, int.MaxValue);
        Debug.DrawLine (boundPoint2, boundPoint8, Color.green, int.MaxValue);
        Debug.DrawLine (boundPoint8, boundPoint4, Color.green, int.MaxValue);
        Debug.DrawLine (boundPoint4, boundPoint6, Color.green, int.MaxValue);

        // bottom of rectangular cuboid (3-7-5-1)
        Debug.DrawLine (boundPoint3, boundPoint7, Color.red, int.MaxValue);
        Debug.DrawLine (boundPoint7, boundPoint5, Color.red, int.MaxValue);
        Debug.DrawLine (boundPoint5, boundPoint1, Color.red, int.MaxValue);
        Debug.DrawLine (boundPoint1, boundPoint3, Color.red, int.MaxValue);

        // legs (6-3, 2-7, 8-5, 4-1)
        Debug.DrawLine (boundPoint6, boundPoint3, Color.yellow, int.MaxValue);
        Debug.DrawLine (boundPoint2, boundPoint7, Color.yellow, int.MaxValue);
        Debug.DrawLine (boundPoint8, boundPoint5, Color.yellow, int.MaxValue);
        Debug.DrawLine (boundPoint4, boundPoint1, Color.yellow, int.MaxValue);
    }

在Unity中如何取得一个Box的Bounds的更多相关文章

  1. 关于Unity中如何判断一个动画播放结束

    方法一(强力推荐): 在动画结束帧或其他帧处加个动画事件,在播放到这一帧的时候会自动调用这个动画函数 如图,找到对应动画的inspector面板,在里面有个Events下拉条,下拉后在想要的帧的位置添 ...

  2. 骨骼动画的原理及在Unity中的使用

    制作骨骼动画 我们看看这几步操作后,我们得到了那些数据: 1.每个皮肤顶点的初始世界坐标. 2.每个骨骼关节顶点的初始世界坐标. 3.每个顶点被骨骼顶点的影响信息. 4.骨骼如何移动. 骨骼动画原理 ...

  3. Unity 中的坐标系

    说明: 注意几点: 0 行向量右乘矩阵与列向量左乘矩阵,两个矩阵互为逆矩阵 1 法线转换与mul,mul函数左乘矩阵当列矩阵计算,右乘当行矩阵计算 2 叉乘与左右手系,左手系用左手,右手系用右手,ax ...

  4. EasyAR SDK在unity中的简单配置及构建一个简单场景。

    首先打开EasyAR的官方网站http://www.easyar.cn/index.html,注册登陆之后,打开首页的开发页面. 下载sdk和Unity Samples. 创建一个unity3d工程N ...

  5. 在Unity中渲染一个黑洞

    在Unity中渲染一个黑洞 前言 N年前观看<星际穿越>时,被其中的"卡冈图雅"黑洞所震撼.制作团队表示这是一个最贴近实际的黑洞效果,因为它是通过各种科学理论实现的.当 ...

  6. unity编辑器扩展_03(在组件中右击创建一个选项,并通过该选项修改该组件下面的字段的值)

    在组件中右击创建一个选项代码: [MenuItem("CONTEXT/PlayerHealth/InitHealth")]    static void Test5()    {  ...

  7. 【Unity优化】构建一个拒绝GC的List

    版权声明:本文为博主原创文章,欢迎转载.请保留博主链接:http://blog.csdn.net/andrewfan 上篇文章<[Unity优化]Unity中究竟能不能使用foreach?> ...

  8. 关于Unity中粒子效果的使用

    粒子效果1: 游戏中会有很炫酷的特效,比如爆炸,水花,火焰等;2: unity提供粒子编辑器,方便特效人员来开发很炫酷的特效;3.粒子效果一般有专门的粒子特效师来做,我们只需要拿来用就好了,很多参数没 ...

  9. 关于Unity中的刚体和碰撞器的相关用法(二)

    在关于Unity中的刚体和碰撞器的相关用法(一)的基础上 有一个plane平面,一个ball球体,都挂了碰撞器,ball挂了刚体Rigidbody,写了一个脚本ball挂载在球体上,球体从空中落下装机 ...

随机推荐

  1. C#面向对象之属性

    1.属性的定义及使用 class MyClass { ; //属性的定义 private string name = ""; //属性的定义 public int Id { get ...

  2. js根据浏览器窗口大小实时改变网页文字大小

    目前,有了css3的rem,给我们的移动端开发带来了前所未有的改变,使得我们的开发更容易,更易兼容很多设备,但这个不在本文讨论的重点中,本文重点说说如何使用js来实时改变网页文字的大小. 代码: &l ...

  3. iOS 程序员 6 级考试(答案和解释)

    iOS 程序员 6 级考试(答案和解释)   我是前言 1. 下面的代码分别输出什么? @implementation Son : Father- (id)init { self = [super i ...

  4. 3Sum Closest

    Given an array S of n integers, find three integers in S such that the sum is closest to a given num ...

  5. [CareerCup] 15.4 Types of Join 各种交

    15.4 What are the different types of joins? Please explain how they differ and why certain types are ...

  6. thinkphp框架验证码验证一次

    做异步验证验证码,只要验证一次结果正确,拿相同的值再次来对比,返回结果就不正确.我看到论坛中有人说,tp框架只要验证过一次正确后验证码就销毁了.确实是这个效果,但具体的还没深入了解

  7. 使用Fiddler截断更改Request数据

    0x01 Fiddler介绍 Fiddler是一个http协议调试代理工具,它能够记录并检查所有你的电脑和互联网之间的http通讯,设置断点,查看所有的“进出”Fiddler的数据.(百度百科) 0x ...

  8. cloudsim安装,配置(到eclipse)

    现在基本成功了.所以将这个过程尽量详细的,准确的分享出来,以供大家的需要.       一.Jdk,Eclipse的安装与配置. 本人下载的jdk版本是1.8,jdk的相关配置网上有很多,我就不赘述了 ...

  9. 使用webbench对不同的web服务器进行压力测试

    1.webbench在linux下的安装步骤,如果安装过程失败,请检查当前用户的执行权限,如果报找不到某个目录的错,请自行创建指定的目录: #wget http://home.tiscali.cz/~ ...

  10. Devexpress TreeList控件绑定显示父子节点对像

    今天一位同事咨询Devexpress TreeList控件绑定自动显示父子节点对像,但结果是不会显示带父子节点关系,而是将所有的节点作为父节点显示出来了,对像类的代码如下 public class I ...