private Vector3 GetModelCenterPoint()
{
Renderer[] renderers = game.transform.GetComponentsInChildren<Renderer>();
Bounds box = new Bounds(new Vector3(0, 0, 0), new Vector3(0, 0, 0));
for (int i = 0; i < renderers.Length; i++)
{
Renderer renderer = renderers[i];
box.Encapsulate(renderer.bounds.min);
box.Encapsulate(renderer.bounds.max);
}
return box.center;
}
Unity 通过包围盒计算模型中心点
于 2024-09-26 14:02:54 首次发布