Game Development Reference
In-Depth Information
Although Unity has a script that virtually “combines children” into a single object, batching is
preferable because it is done after it is determined which objects are within the viewing frustum.
Combining objects in different areas of the scene would cause a slowdown in frustum culling. An
object's bounding box is checked first; if any part of the box is within the frustum, each face or
triangle is then checked to see if it is within the frustum and must be drawn. An object that has
meshes in and out of scene at any one time must always have each face checked, costing frame
rate while doing so.
Static batching, available in Unity Pro only, is significantly more efficient because it can batch
objects of any size as long as they are static and share the same material.
If you have Unity Pro, you have the option to use Dynamic Batching.
1.
In the Project view, open the CornerGarden asset and inspect each of the
meshes used to create the garden enclosure (Figure 4-17 ).
Figure 4-17. The meshes that make up the CornerGarden asset
As you select each one, note the vertex count shown in the Preview window of the Inspector.
To get accurate results for the batching, all of the objects must be within the viewing frustum (the
screen's bounds) in Play mode. You had a First Person Controller to direct the camera in your terrain
test scene. At present, you have a camera but no means of directing it at runtime, so you will have to
set it up before you press Play.
2.
Arrange the Scene view to be able to see all of the objects.
3.
Select the Main Camera.
4.
From the GameObject menu, select Align With View.
The camera's view now matches the Scene's view (Figure 4-18 ).
Search WWH ::




Custom Search