---
title: "Lesson 6.1 - Project Optimization"
content_type: tutorial
url: "https://learn.unity.com/course/create-with-code/unit/next-steps/tutorial/lesson-6-1-project-optimization-1?language=en"
language: en
container_type: course
container_title: "Create with Code"
container_url: "https://learn.unity.com/course/create-with-code.md?language=en&version=6.0"
unit_title: "Next Steps"
unit_url: "https://learn.unity.com/course/create-with-code/unit/next-steps?language=en&version=6.0"
standalone_markdown_url: "https://learn.unity.com/tutorial/lesson-6-1-project-optimization-1.md?language=en&version=6.0"
previous_title: "Next Steps - Introduction"
previous_url: "https://learn.unity.com/course/create-with-code/unit/next-steps/tutorial/next-steps-introduction?language=en&version=6.0"
previous_markdown_url: "https://learn.unity.com/course/create-with-code/unit/next-steps/tutorial/next-steps-introduction.md?language=en&version=6.0"
next_title: "Lesson 6.2 - Research and Troubleshooting"
next_url: "https://learn.unity.com/course/create-with-code/unit/next-steps/tutorial/lesson-6-2-research-and-troubleshooting-2?language=en&version=6.0"
next_markdown_url: "https://learn.unity.com/course/create-with-code/unit/next-steps/tutorial/lesson-6-2-research-and-troubleshooting-2.md?language=en&version=6.0"
difficulty: beginner
duration_minutes: 30
unity_version:
  - "6.0"
  - "6.3"
supported_unity_versions:
  - name: "6.0"
    url: "https://learn.unity.com/course/create-with-code/unit/next-steps/tutorial/lesson-6-1-project-optimization-1.md?language=en&version=6.0"
  - name: "6.3"
    url: "https://learn.unity.com/tutorial/lesson-6-1-project-optimization-1.md?language=en&version=6.3"
  - name: "2022.3"
    url: "https://learn.unity.com/course/create-with-code/unit/next-steps/tutorial/lesson-6-1-project-optimization-1.md?language=en&version=2022.3"
  - name: "2021.3"
    url: "https://learn.unity.com/course/create-with-code/unit/next-steps/tutorial/lesson-6-1-project-optimization-1.md?language=en&version=2021.3"
last_updated: "2026-08-04T14:23:16.000Z"
---

# Lesson 6.1 - Project Optimization

Explore core optimization techniques to boost project performance, especially for larger mobile and web builds.


**Overview:**

In this lesson, you will learn about a variety of different techniques to optimize your projects and make them more performant. You may not notice a huge difference in these small prototype projects, but when you’re exporting a larger project, especially one for mobile or web, every bit of performance improvement is critical.

**Project Outcome:**

Several of your prototype projects will have improved optimization, serving as examples for you to implement in your personal projects

## Materials

- [Object Pooling.zip](<https://unity-connect-prd.storage.googleapis.com/20200422/b9f723f1-2e90-4b7a-872b-379160bf81d0/Object Pooling.zip>)

## 1. Variable Attributes

In the course, we only ever used “public” or “private” variables, but there are a lot of other variable attributes you should be familiar with.

[Video](https://connect-mediagw.unity.com/h1/20241208/videos/611ac03f-3006-4ddb-85c4-c7e65c1698fb_CWC_U6_L1_S1_U6.mp4) ([Transcript (en)](https://storage.googleapis.com/learn-platform-bucket-production/tutorial/8fd27a44-aa3b-49c2-a466-64d4ae94dd1b/versions%5B_key==%22c1c17e97860a%22%5D.sections%5B_key==%22HDmOj4kM4HVkJkWHXY1vsz%22%5D.body%5B_key==%22HDmOj4kM4HVkJkWHXY1vxr%22%5D.subtitles/Lesson%206.1%20-%201.%20Variable%20Attributes_20260623_015526.vtt))

1. Open your **Prototype 1** project and open the **PlayerController.cs** script
2. Add **\[SerializeField\]** at the beginning of the line for your private attributes, then edit the values in the Inspector
3. In **FollowPlayer.cs**, add the **\[SerializeField\]** attribute to the Vector3 **offset** variable
4. Try applying the “**readonly**”, “**const**”, or “**static**” attributes, noticing that all have the effect of removing the variable from the inspector

![](https://connect-mediagw.unity.com/h1/20250522/learn/images/6fb4d094-fb68-442c-a93f-12eaab66ace6_6.1.1._Variable_Attributes.png)

## 2. Unity Event Functions

In the course we only ever used the default Update() and Start() event functions, but there are others you might want to use in different circumstances.

[Video](https://connect-mediagw.unity.com/h1/20241208/videos/6d422acc-5f6c-4bd1-b130-64063639175c_CWC_U6_L1_S2_U6.mp4) ([Transcript (en)](https://storage.googleapis.com/learn-platform-bucket-production/tutorial/8fd27a44-aa3b-49c2-a466-64d4ae94dd1b/versions%5B_key==%22c1c17e97860a%22%5D.sections%5B_key==%22HDmOj4kM4HVkJkWHXY1wwk%22%5D.body%5B_key==%22HDmOj4kM4HVkJkWHXY1x1c%22%5D.subtitles/Lesson%206.1%20-%202.%20Unity%20Event%20Functions%20%20_20260623_015542.vtt))

1. **Duplicate** your main Camera, rename it “Secondary Camera”, then **deactivate** the Main Camera
2. **Reposition** the Secondary camera in a first-person view, then edit the **offset variable** to match that position
3. Run your project and notice how choppy it is
4. In **PlayerController**.cs, change “Update” to “FixedUpdate”, and in **FollowPlayer**.cs, change “Update” to “LateUpdate”, then **test again**
5. **Delete** the Start() function in both scripts, then reactivate your Main Camera

![](https://connect-mediagw.unity.com/h1/20190702/learn/images/148bf603-7d52-41c5-8031-00d27ea26245_Screen_Shot_2019_07_02_at_4.09.41_PM.png)

## 3. Object Pooling

Throughout the course, we’ve created a lot of prototypes that instantiated and destroyed objects during gameplay, but there’s actually a more performant / efficient way to do that called Object Pooling.

[Video](https://connect-mediagw.unity.com/h1/20241208/videos/7646af52-55a5-464e-842e-45a7143c4a77_CWC_U6_L1_S3_U6.mp4) ([Transcript (en)](https://storage.googleapis.com/learn-platform-bucket-production/tutorial/8fd27a44-aa3b-49c2-a466-64d4ae94dd1b/versions%5B_key==%22c1c17e97860a%22%5D.sections%5B_key==%22HDmOj4kM4HVkJkWHXY1y2w%22%5D.body%5B_key==%22HDmOj4kM4HVkJkWHXY1y7o%22%5D.subtitles/Lesson%206.1%20-%203.%20Object%20Pooling_20260623_015600.vtt))

1. Open **Prototype 2** and create a backup
   1. Delete the **DetectCollisions**, **PlayerController**, and **DestroyOutOfBounds** scripts from your project
2. **Download** the **[Object Pooling](https://unity-connect-prd.storage.googleapis.com/20200422/b9f723f1-2e90-4b7a-872b-379160bf81d0/Object%20Pooling.zip)** unity package and **import** it into your scene
3. Reattach the **PlayerController** script to your player. Reattach **DestroyOutOfBounds** script to your animal and food prefabs, and then reattach the **DetectCollisions** script to your animal prefabs (**_not_** to your food prefab)
4. Attach the **ObjectPooler** script to your Spawn Manager, drag your food projectile into the “**Objects To Pool**” variable, and set the “**Amount To Pool**” to 20
5. **Run** your project and see how the projectiles are activated and deactivated

## 4. Lesson Recap

**New Concepts and Skills**

- Optimization
- Serialized Fields
- readonly / const / static / protected
- Event Functions
- FixedUpdate() vs. Update() vs. LateUpdate()
- Awake() vs. Start()
- Object Pooling
