惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
CERT Recently Published Vulnerability Notes
V
Vulnerabilities – Threatpost
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
L
Lohrmann on Cybersecurity
C
CXSECURITY Database RSS Feed - CXSecurity.com
Schneier on Security
Schneier on Security
T
Threatpost
P
Proofpoint News Feed
MongoDB | Blog
MongoDB | Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
大猫的无限游戏
大猫的无限游戏
T
Threat Research - Cisco Blogs
罗磊的独立博客
Security Latest
Security Latest
D
Docker
S
Secure Thoughts
博客园 - 聂微东
A
Arctic Wolf
Recorded Future
Recorded Future
雷峰网
雷峰网
Microsoft Azure Blog
Microsoft Azure Blog
The Cloudflare Blog
P
Palo Alto Networks Blog
Project Zero
Project Zero
Blog — PlanetScale
Blog — PlanetScale
D
Darknet – Hacking Tools, Hacker News & Cyber Security
H
Help Net Security
T
The Blog of Author Tim Ferriss
Latest news
Latest news
AWS News Blog
AWS News Blog
U
Unit 42
Stack Overflow Blog
Stack Overflow Blog
The GitHub Blog
The GitHub Blog
Know Your Adversary
Know Your Adversary
Vercel News
Vercel News
WordPress大学
WordPress大学
Spread Privacy
Spread Privacy
F
Full Disclosure
Martin Fowler
Martin Fowler
T
The Exploit Database - CXSecurity.com
Attack and Defense Labs
Attack and Defense Labs
Y
Y Combinator Blog
Microsoft Security Blog
Microsoft Security Blog
V
V2EX
M
MIT News - Artificial intelligence
P
Proofpoint News Feed
小众软件
小众软件
宝玉的分享
宝玉的分享

博客园 - 工具人Kim哥

mysql数据库备份命令大全 Vue获取url网址参数的两种方法 在vscode下编译vue神坑40% building 过不去 PHP获取本周的每一天的时间 vue元素对齐方式 一个身高体重测量工具(BMI测量工具) HTML代码格式化实现方式 一个不错的常用小工具站点 Fiddler使用 不错的SDL源码分析 PPT文化 Unity消息 Unity3D中的UnitySendMessage方法的使用 Android性能优化之渲染 问题记录 VS2012项目中使用CocoStudio相关文件的设置 国际金融基础知识 Nutch 安装文档 sed linux 命令
unity3d中获得物体的size
工具人Kim哥 · 2015-05-18 · via 博客园 - 工具人Kim哥

以size的x方向为例

1:gameObject.renderer.bounds.size.x;//这个值的结果真实反应出有MeshRenderer这个组件的模型的尺寸。不需要再乘以localScale.x。

2:gameObject.GetComponent<MeshFilter>().mesh.bounds.size.x;//通过MeshFilter获得原始模型的mesh,该值返回的结果是原始mesh的尺寸。

若要获得模型的尺寸大小还需要乘以模型的localScale.x。

即:gameObject.GetComponent<MeshFilter>().mesh.bounds.size.x*gameObject.transform.localScale.x;

3:为物体添加Collider,然后使用XXX.collider.bounds.size;

这个不一定能很好的反应物体的大小,bounds获得的是物体的外包矩形。而且这个外包矩形的X,Y,Z和世界坐标一致。因此,若物体有旋转,获得的尺寸就不能反应出物体的真实大小,只是其外包矩形的大小。。。

如:获得terrain的尺寸

        terrainWidth = terrain.collider.bounds.size.x;

        terrainLength = terrain.collider.bounds.size.z;

        terrainHeight = terrain.collider.bounds.size.y;

4:代码实现获得复杂物体的尺寸(诸如根节点没有MeshFilter,MeshRenderer组件,物体是由很多复杂不规则的小mesh子物体组成的)
如:

Camera的口径Size

当投影类型为Perspective时,fieldOfView属性表示口径的度数,范围为[1,179]

当投影类型为Orthgraphic,     orthographicSize属性为正交模式下的口径尺寸