Game Development Reference
In-Depth Information
This code breaks down as follows:
(1) public var frameRate : int = 50;
Declare a public variable frameRate of type int so you can adjust it from
the Inspector.
1.
(2) Application.targetFrameRate = frameRate;
2. Set the Application class targetFrameRate to the value held by frameRate .
Save the script. In the Unity Editor top menu, select Game Object ➤ Create Empty and name it
TargetFrameRate. Attach the SetTargetFrameRate script, save the scene, and play. Notice that the
FPS doesn't hold at precisely 50 and might even appear to have no effect. This is because the target
frame rate is not an absolute limit. To see a more noticeable difference in the stats, change the
Frame Rate to 25, play again, and you'll see the FPS in the stats window vary in a range closer to 25.
As you review the Application.targetFrameRate documentation in the Scripting reference, you'll
see that setting it to -1 is a default value that sets web player games to a 50-60 fps target and tells
standalones to simply render as fast as they can. Don't forget to change Frame Rate back to 50
when you're done.
When and Where to Optimize
Optimization decisions made during the design phase are largely based on known limitations of the
target platform. During development, following best practice recommendations prevents degraded
performance from inefficient development techniques. Beyond that, the optimization process
becomes very dynamic in response to the unique characteristics of the game as the myriad details
that can affect performance come together.
Design Phase
More decisions than just choosing the target frame rate occur in the design phase. When considering
the game art, the target platform's capabilities come into play. A general practice is not to use any
more vertices for a model than is necessary, but the CPU rendering limitation is based on everything
within the scene, including other factors such as the use of color, light, and shadows, not just one
model or another. Refer to the documentation of the target platform for specifics.
Mobile devices generally can't handle more than 100,000 vertices, while PCs are more on the order
of several million. You might choose a much lower level of background detail for a mobile game than
you would for a PC-based game to preserve the detail of your primary game object models.
Another mobile device limitation is in file size for downloading. Incorporating the reuse of models,
textures, and materials into the game design helps to keep the overall file size down.
 
Search WWH ::




Custom Search