Chapter 11. Debugging and Optimization

Now that we have a nearly completed project it's time to start working on getting as much performance out of the system as possible. While we would normally address performance throughout the development process, I felt it was important to look at the project further along, so that we could see how to reengineer the product based on some questionable decisions we might have made earlier in the project. By doing it this way it will be possible to see these decisions within the context of how we might normally build an application.

In this chapter we shall:

  • Learn about debugging options in Unity
  • Learn how to profile a mobile application
  • Learn about object pooling and why it's crucial on mobile devices
  • Learn how to optimize lighting with Beast Lighting

This chapter is where we will highlight some of the key differences between making a game for Unity and making one for Unity on a mobile device. This chapter will make the biggest difference between our application being a hit and it just bring a pretty showpiece that people uninstall a few hours after launching it.

Debugging

Unity possesses a debugger that is a first-class citizen with the rest of the Unity platform. The debugger will allow you to put breakpoints directly in your Unity scripts, and while the game is running on the target device, allow you to pause the game's execution to enable observation or tweaking of variables. This is a very powerful approach that is often times missing when developing for a device. In the past, the best one could do is emit sounds or change screen colors when certain conditions were met. Today you can watch the values of variables change, make modifications to scripts that are executing on the device, and change the flow of execution of the game dynamically without much impact to the game's frame rate. So let's take a look at how we make this magic happen.

Debugging a running application on real hardware is something that you need to be very comfortable with. While Unity can do an admirable job of helping you simulate your content on your Mac, there is nothing that beats knowing how your application will perform in the wild.

A breakpoint is a place in your game where you want to pause the execution of the application for debugging purposes. As the Unity scripting environment, MonoDevelop, is integrated with the Unity IDE, and consequently the runtime, we can insert breakpoints in our scripts, which will trigger the pause in execution.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.3.154