我的场景有一个 GameObject 作为它的根,一个 LineRenderer 作为它的子级。
在 LineRenderer 上调用 BakeMesh 时,它工作正常。如果我使用 Instantiate
复制 LineRenderer,然后调用 BakeMesh,它会失败。
简化代码:
LineRenderer lineRenderer = m_GameWorld.GetComponentInChildren<LineRenderer>();
Transform rootTransform = m_GameWorld.transform;
Debug.Log("Baking mesh using a the original LineRenderer");
m_Path = lineRenderer;
m_Path.BakeMesh(new Mesh(), true);
Debug.Log("Baking mesh using a copy of LineRenderer");
m_Path = Instantiate(lineRenderer, rootTransform);
m_Path.BakeMesh(new Mesh(), true);
Debug.Log("Done");
输出结果是:
Baking mesh using a the original LineRenderer
Baking mesh using a copy of LineRenderer
Mesh '': abnormal mesh bounds - most likely it has some invalid vertices (+/-inifinity or NANs) due to errors exporting.
Mesh bounds min=(-244756620798551190644195328.00, 0.00, 0.00), max=(0.00, 5.21, 21341459879620077536841802664902656.00). Please make sure the mesh is exported without any errors.
Done
当 useTransform
的第二个参数 BakeMesh
设置为 False 时不会发生错误。
这似乎是一个 Unity 错误 - 但我可能误解了 Instantiate
的复杂性?
答案 0 :(得分:0)
刚遇到同样的问题。使用 m_Path.BakeMesh(new Mesh(), false)
为我修复了它。因此,转换的规模以某种方式打破了它。但是,在调用 BakeMesh 之前设置比例似乎并没有修复它。