/// <summary>
/// 计算模型的中心点
/// </summary>
private Vector3 GetBoundPointsByObj(GameObject obj)
{
var bounds = new Bounds(obj.transform.position, Vector3.zero);
if (obj != null)
{
var renders = obj.GetComponentsInChildren<Renderer>();
if (renders != null)
{
foreach (var item in renders)
{
bounds.Encapsulate(item.bounds);
}
}
}
//Debug.Log(bounds);
return bounds.center + new Vector3(0, bounds.extents.y, 0);
}
计算模型中心点
于 2022-07-19 17:53:15 首次发布