using UnityEngine;
using System.Collections;
public class BoundUtil : MonoBehaviour
{
private Vector3 min = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);
private Vector3 max = new Vector3(float.MinValue, float.MinValue, float.MinValue);
// Use this for initialization
void Start () {
Search(transform, ref min, ref max);
}
// Update is called once per frame
void Update () {
DrawBound(min, max);
}
/// <summary>
/// 递归计算所有子物体的范围
/// </summary>
/// <param name="tf">需要计算范围的模型变换</param>
/// <param name="min"></param>
/// <param name="max"></param>
private void Search(Transform tf,ref Vector3 min,ref Vector3 max)
{
MeshFilter mFilter = tf.GetComponent<MeshFilter>();
if (mFilter != null && mFilter.mesh != nul