在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挂载在球体上,球体从空中落下装机 ...
随机推荐
- ThinkPHP 分页类的使用及退出功能的实现
/* ThinkPHP设置编码统一: 一.数据库设置为utf8_bin 二.HTML页面设置charset=utf-8,而且检查文档编码格式是否是utf-8.phpDesigner8设置方式为“文件- ...
- IOS 蓝牙相关-app作为外设被连接的实现(3)
再上一节说了app作为central连接peripheral的情况,这一节介绍如何使用app发布一个peripheral,给其他的central连接 还是这张图,central模式用的都是左边的类,而 ...
- IOS UINavigationController 导航控制器
/** 导航控制器掌握: 1.创建导航控制器 UINavigationController *nav = [[UINavigationController alloc] initWithRootVie ...
- (转载)zeromq使用注意点滴
zeromq使用注意点滴 1.关于介绍zeromq的就不说了,可以自己去看官方guide很详细 2.主要说下在使用过程中需要注意的地方 1)使用如果使用c++的接口的时候,在你自己的类中或者apach ...
- org.openqa.selenium.StaleElementReferenceException
org.openqa.selenium.StaleElementReferenceException如何解啊.什么原因造成的,貌似有时会出现,有时不会出现
- Linux下安装JDK和tomcat
1.新建用户 2.解压 jdk-7u67-linux-x64.tar.gz 到本地 3.配置环境变量 编辑.bash_profile文件 4.生效 5.安装tomcat 6.验证tomcat是否安装成 ...
- (转)深入理解flash重绘
深入理解Flash Player重绘 Flash Player 会以SWF内容的帧频速度来刷新需要变化的内容,而这个刷新的过程,我们通常称为“重绘(redraw)”,相信即便是初级的菜鸟也知道,只要使 ...
- 利用Jquery给当前页或者跳转后页面的导航栏添加选中后样式
具体的样式有两种情况,一种是直接给当前页面添加特殊样式,当网页刷新或者跳转到下一页后,样式消失:另一种情况是即使刷新页面后样式仍然有效. 直接上代码: 第一种情况: 在CODE上查看代码片派生到我的代 ...
- select在各个浏览器中的兼容性问题
我们知道select标签在各个浏览器中的属性和各浏览器的支持各有些不同,从而造成select选择框在各浏览器的显示有不同. 下面我们通过对主要CSS属性的支持,打造全兼容select. 对select ...
- 自己做的一个小demo
上图: 主段代码: <script type="text/javascript"> var getRandomColor = function(){ return (f ...