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. [BZOJ2790][Poi2012]Distance

    2790: [Poi2012]Distance Time Limit: 40 Sec  Memory Limit: 128 MBSubmit: 225  Solved: 115[Submit][Sta ...

  2. 【noiOJ】p8208

    03:切分矩形组 查看 提交 统计 提问 总时间限制:  1000ms 内存限制:  65536kB 描述 给定若干个平行于坐标轴的互不重叠的矩形,矩形的顶点都是整点.要求画一根平行于y轴的直线x=k ...

  3. petapoco定制,比较SQL事务,存储过程,分布式事务(MSDTC)的区别和场景

    使用分布式事务时 就锁死了,而且是只锁编辑的行 使用.netSQL事务一定要执行了一个CUD的SQL才会锁死,而且也是锁行,但是也锁读的行 .netSQL事务要在这里才锁死 结论,对于产品要求细粒度的 ...

  4. 熟悉Eclipse开发工具

    一.熟悉Eclipse 1.Eclipse是由IBM公司投资4000万美元开发的集成开发工具.它基于Java语言编写,并且是开放源代码的.可扩展的,也是目前最流行的Java集成开发工具之一.另外,IB ...

  5. 使用 CSS 去掉 iPhone 网页上按钮的超大圆角以及文本框圆角默认样式

    使用 iPhone 上的浏览器去浏览网页的时候,按钮总是显示超大圆角且颜色由上而下渐变的样式,显得超级恶心,而且文本框也会有一定的圆角,但是我们自己定义 border-radius 也没有效果,经过搜 ...

  6. 30.编写一个Shape类,具有属性:周长和面积; 定义其子类三角形和矩形,分别具有求周长的方法。 定义主类E,在其main方法中创建三角形和矩形类的对象, 并赋给Shape类的对象a、b,使用对象a、b来测试其特性。

    package zuoye8; public abstract class Shape { private double zhouchang ; private double mianji ; pub ...

  7. hadoop配置远程客户端

    独立出一台机器,作为客户端,可以连接远程集群,配置注意事项: 1.首先是hive,需要服务器启动一个服务 hive --service metastore 然后修改hive客户端 hive-site. ...

  8. Hibernate的一级二级缓存机制配置与测试

    特别感谢http://www.cnblogs.com/xiaoluo501395377/p/3377604.html 在本篇随笔里将会分析一下hibernate的缓存机制,包括一级缓存(session ...

  9. C# - 时间格式

    如果是字符串,需要先转化为DateTime格式 DateTime ExDate = DateTime.Parse(dt.Rows[]["HKMonth"].ToNotNullStr ...

  10. 创建 PDO 实例并在构造函数中设置错误模式

    PDO 将只简单地设置错误码,可使用 PDO::errorCode() 和 PDO::errorInfo() 方法来检查语句和数据库对象.如果错误是由于对语句对象的调用而产生的,那么可以调用那个对象的 ...