Challenge - Optimize the Project Scripts

Tutorial

·

intermediate

·

+0XP

·

10 mins

·

(48)

Unity Technologies

Challenge - Optimize the Project Scripts

In this tutorial, you will use the Profiler window to determine where you can improve a scripts performance.

Languages available:

1. Identifying the Problem

1. Use the Profiler to identify a problematic performance
a. Open the Profiler in Unity, by going to Window > Analysis > Profiler.
b. Play the game and observe the performance profile using Deep Profile if necessary
c. Identify the AI Behavior as a hindrance to performance


Figure 01: Profiling the Scenes performance

Figure 01: Profiling the Scenes performance


d. Record the profile data to use as a baseline (never optimize without a baseline)


2. Optimizing the Script

1. Optimize the AI Behavior
a. Open the SimpleAI script
b. Determine the problematic section of the code


Figure 02: Finding the culprit in the SimpleAI script

Figure 02: Finding the culprit in the SimpleAI script


c. Fix the code section by commenting out the culprit


Figure 03: Commenting out the Culprit

Figure 03: Commenting out the Culprit


3. Analyzing the Result

1. Use the Profiler to analyze the results
a. Open the Profiler in Unity
b. Play the game and observe the performance profile
c. Compare to your benchmark


Figure 04: Viewing the result of the script optimization

Figure 04: Viewing the result of the script optimization


Complete this tutorial