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. HDU 4003 Find Metal Mineral(分组背包+树形DP)

    题目链接 很棒的一个树形DP.学的太渣了. #include <cstdio> #include <string> #include <cstring> #incl ...

  2. 【Oracle】悲观锁和乐观锁

    悲观锁     如select * for update     悲观锁大多数情况下依靠数据库的锁机制实现,以保证操作最大程度的独占性.但随之而来的就是数据库性能的大量开销,特别是对长事务而言,这样  ...

  3. ASP.NET状态保持方案若干

    客户端方案: 1.ViewState 2.隐藏域 3.cookie 大小4KB限制,不消耗服务器资源,可配置到期时间,但安全性不高,还被客户端禁用. 4.QueryString 方法简单,但不安全,有 ...

  4. C#注意事项及错误处理

    1 使用到config文件配置数据库路径 ConfigurationManager.ConnectionStrings["dbPath"].ConnectionString; db ...

  5. 简短总结一下C#里跨线程更新UI(转)

    摘自: http://my.oschina.net/sdqxcxh/blog/53707 跨线程更新UI是写多线程程序尤其是通信类的程序经常遇到的问题,这里面主要的问题是冲突,比如数据线程想要更新UI ...

  6. HttpWebRequest Post callback

    public void GetValueFromRequest(string postData) { var request = (HttpWebRequest) WebRequest.CreateH ...

  7. Enumerators and Enumerable

    Next week task is to learn how generic enumeration interface works, try to build a sample and write ...

  8. Point Grey articles link

    Point Grey areaDetector driver Bumblebee XB3 Specifications FlyCapture SDK Example Source Code Under ...

  9. thinkphp条件查询和模糊查询的一些方法

    #文章管理 public function adminArticle(){ $adminArticle=M("article"); $arr_seach=$this->sea ...

  10. bzoj3732: Network--kruskal最小生成树+LCA

    这是一道写起来比较顺手的题目 没有各种奇怪的细节,基本就是Kruskal和倍增LCA的模板.. 题目大意:对于一个无向带权图,询问两点之间一条路,使得这条路上的最长边最小,输出最小最长边的的值 那么既 ...