c# - Unity 中关于实例化对象的 AABB 错误的原因是什么?
问题描述
已编辑: 显示错误日志的图像。所以我有一个脚本来识别项目列表,删除当前项目,然后重新生成原始对象。这在 80% 的情况下有效,但在其他 20 次出现 AABB 错误,我不知道原因是什么。有任何想法吗?
解决方案
AABB 与表示轴对齐边界框的边界框有关。您的 AABB 可能没有正确对齐,这就是您收到错误的原因。有一个脚本显示您的对象如何绘制它们的边界框,以便您可以轻松设置它们。
using UnityEngine;
using System.Collections;
public class BoundingBox: MonoBehaviour
{
void OnDrawGizmos()
{
Renderer rend = GetComponent<Renderer>();
if (rend)
{
Gizmos.color = Color.yellow;
Gizmos.DrawWireCube(rend.bounds.center, rend.bounds.size);
}
}
//If your object is not within the bounding boundaries, then you can set your mesh up manually like this;
void Start()
{
var meshFilter = GetComponent<MeshFilter>();
meshFilter.mesh.bounds = new Bounds(transform.position, new Vector3(10, 5, 1));
}
}
推荐阅读
- r - 函数唯一更改R中data.frame中列的数据类型
- python - 读取多个 rstp 流并使用 opencv 写入磁盘时延迟和 fps 下降
- python - Pandas 根据条件创建单独的 DF
- python - 岭回归中的手动交叉验证导致每个 lambda 的 MSE 相同
- javascript - 如何删除所有出现的相同 Web 部件列表的标题
- java - 列表随机变为空 - Java
- android-studio - 在 Android Studio logcat 中将对象显示为 Gson
- java - 这段代码在 Spring 中使用事务管理有什么问题
- database - Laravel 将任何模型变形为用户模型
- django-urls - 找不到网址 - Django python