在Unity中如何取得一个Box的Bounds

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的更多相关文章
- 关于Unity中如何判断一个动画播放结束
方法一(强力推荐): 在动画结束帧或其他帧处加个动画事件,在播放到这一帧的时候会自动调用这个动画函数 如图,找到对应动画的inspector面板,在里面有个Events下拉条,下拉后在想要的帧的位置添 ...
- 骨骼动画的原理及在Unity中的使用
制作骨骼动画 我们看看这几步操作后,我们得到了那些数据: 1.每个皮肤顶点的初始世界坐标. 2.每个骨骼关节顶点的初始世界坐标. 3.每个顶点被骨骼顶点的影响信息. 4.骨骼如何移动. 骨骼动画原理 ...
- Unity 中的坐标系
说明: 注意几点: 0 行向量右乘矩阵与列向量左乘矩阵,两个矩阵互为逆矩阵 1 法线转换与mul,mul函数左乘矩阵当列矩阵计算,右乘当行矩阵计算 2 叉乘与左右手系,左手系用左手,右手系用右手,ax ...
- EasyAR SDK在unity中的简单配置及构建一个简单场景。
首先打开EasyAR的官方网站http://www.easyar.cn/index.html,注册登陆之后,打开首页的开发页面. 下载sdk和Unity Samples. 创建一个unity3d工程N ...
- 在Unity中渲染一个黑洞
在Unity中渲染一个黑洞 前言 N年前观看<星际穿越>时,被其中的"卡冈图雅"黑洞所震撼.制作团队表示这是一个最贴近实际的黑洞效果,因为它是通过各种科学理论实现的.当 ...
- unity编辑器扩展_03(在组件中右击创建一个选项,并通过该选项修改该组件下面的字段的值)
在组件中右击创建一个选项代码: [MenuItem("CONTEXT/PlayerHealth/InitHealth")] static void Test5() { ...
- 【Unity优化】构建一个拒绝GC的List
版权声明:本文为博主原创文章,欢迎转载.请保留博主链接:http://blog.csdn.net/andrewfan 上篇文章<[Unity优化]Unity中究竟能不能使用foreach?> ...
- 关于Unity中粒子效果的使用
粒子效果1: 游戏中会有很炫酷的特效,比如爆炸,水花,火焰等;2: unity提供粒子编辑器,方便特效人员来开发很炫酷的特效;3.粒子效果一般有专门的粒子特效师来做,我们只需要拿来用就好了,很多参数没 ...
- 关于Unity中的刚体和碰撞器的相关用法(二)
在关于Unity中的刚体和碰撞器的相关用法(一)的基础上 有一个plane平面,一个ball球体,都挂了碰撞器,ball挂了刚体Rigidbody,写了一个脚本ball挂载在球体上,球体从空中落下装机 ...
随机推荐
- BZOJ4500: 矩阵
Description 有一个n*m的矩阵,初始每个格子的权值都为0,可以对矩阵执行两种操作: 1. 选择一行, 该行每个格子的权值加1或减1. 2. 选择一列, 该列每个格子的权值加1或减1. 现在 ...
- Linux 获取设备树源文件(DTS)里描述的资源
Linux 获取设备树源文件(DTS)里的资源 韩大卫@吉林师范大学 在linux使用platform_driver_register() 注册 platform_driver 时, 需要在 plat ...
- JAVA复制网络图片到本地
import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.io.Out ...
- 练习一:SQLite基本操作
一.基础知识: 运用场景: 1>应用运行需要保存一系列有一定关系有一定结构的数据(文本也可以但是存储效率低) 2>文件类型:.db(一个数据库就是一个.db文件) 3>路径:/dat ...
- android几个实用的判定代码
之前项目有几个判定代码很实用,特此做一个整理. 一.验证手机格式是否正确 //判断手机号码是否合理 private boolean judgePhoneNums(String phoneNums) { ...
- zk 隐藏网页文件后缀
前台(test.zul): <a label="隐藏地址" href="/Bandbox/test.html"/> web.xml添加 <se ...
- bootstrap使用性能问题
1.如icheckbox等的初始化,不要采用类似for in的循环来对所需应用的元素进行初始化,直接采用如 $('[data-toggle="popover"]').popove ...
- [转]Oracle数据库ASH和AWR的简单介绍
在Oracle数据库中,有时我们可能会遇到这样的术语:ASH和AWR,那么它们是怎样产生的呢?它们的作用又是什么呢?本文我们就来介绍这一部分内容. 1.10g之前 用户的连接将产生会话,当 ...
- apache本地域名ip重定向vhosts
apache本地域名ip重定向,使本机通过指定域名访问到指定ip路径. 1.apache配置apache/conf/httpd.conf : 开启配置 Include conf/extra/http ...
- window dos命名
dos命令从c盘进入d盘c:\>d:敲回车 >dir 查看文件夹中文件运行java程序,最好先进入文件夹:然后javac Hello.javajava Hello