QueryInBounds() public method

public QueryInBounds ( Rect bounds, List buffer ) : void
bounds UnityEngine.Rect
buffer List
return void
Ejemplo n.º 1
0
 public static void GetAllInBounds(List <RecastMeshObj> buffer, Bounds bounds)
 {
     if (!Application.isPlaying)
     {
         RecastMeshObj[] objArray = UnityEngine.Object.FindObjectsOfType(typeof(RecastMeshObj)) as RecastMeshObj[];
         for (int i = 0; i < objArray.Length; i++)
         {
             objArray[i].RecalculateBounds();
             if (objArray[i].GetBounds().Intersects(bounds))
             {
                 buffer.Add(objArray[i]);
             }
         }
     }
     else
     {
         if (Time.timeSinceLevelLoad == 0f)
         {
             RecastMeshObj[] objArray2 = UnityEngine.Object.FindObjectsOfType(typeof(RecastMeshObj)) as RecastMeshObj[];
             for (int k = 0; k < objArray2.Length; k++)
             {
                 objArray2[k].Register();
             }
         }
         for (int j = 0; j < dynamicMeshObjs.Count; j++)
         {
             if (dynamicMeshObjs[j].GetBounds().Intersects(bounds))
             {
                 buffer.Add(dynamicMeshObjs[j]);
             }
         }
         Rect rect = Rect.MinMaxRect(bounds.min.x, bounds.min.z, bounds.max.x, bounds.max.z);
         tree.QueryInBounds(rect, buffer);
     }
 }
Ejemplo n.º 2
0
        /** Fills the buffer with all RecastMeshObjs which intersect the specified bounds */
        public static void GetAllInBounds(List <RecastMeshObj> buffer, Bounds bounds)
        {
            if (!Application.isPlaying)
            {
                RecastMeshObj[] objs = FindObjectsOfType(typeof(RecastMeshObj)) as RecastMeshObj[];
                for (int i = 0; i < objs.Length; i++)
                {
                    objs[i].RecalculateBounds();
                    if (objs[i].GetBounds().Intersects(bounds))
                    {
                        buffer.Add(objs[i]);
                    }
                }
                return;
            }
            else if (Time.timeSinceLevelLoad == 0)
            {
                //Is is not guaranteed that all RecastMeshObj OnEnable functions have been called, so if it is the first frame since loading a new level
                //try to initialize all RecastMeshObj objects.
                RecastMeshObj[] objs = FindObjectsOfType(typeof(RecastMeshObj)) as RecastMeshObj[];
                for (int i = 0; i < objs.Length; i++)
                {
                    objs[i].Register();
                }
            }

            for (int q = 0; q < dynamicMeshObjs.Count; q++)
            {
                if (dynamicMeshObjs[q].GetBounds().Intersects(bounds))
                {
                    buffer.Add(dynamicMeshObjs[q]);
                }
            }

            Rect r = Rect.MinMaxRect(bounds.min.x, bounds.min.z, bounds.max.x, bounds.max.z);

            tree.QueryInBounds(r, buffer);
        }