---
title: "レッスン 6.1 - プロジェクトの最適化"
content_type: tutorial
url: "https://learn.unity.com/tutorial/lesson-6-1-project-optimization-jp?language=ja"
language: ja
difficulty: beginner
duration_minutes: 30
unity_version:
  - "2022.3"
  - "2022.2"
  - "2022.1"
  - "2021.3"
  - "2021.2"
  - "2021.1"
  - "2020.3"
  - "2020.2"
  - "2020.1"
  - "2019.4"
  - "2019.3"
  - "2019.2"
  - "2019.1"
  - "2018.4"
supported_unity_versions:
  - name: "2022.3"
    url: "https://learn.unity.com/tutorial/lesson-6-1-project-optimization-jp.md?language=ja&version=2022.3"
  - name: "2022.2"
    url: "https://learn.unity.com/tutorial/lesson-6-1-project-optimization-jp.md?language=ja&version=2022.2"
  - name: "2022.1"
    url: "https://learn.unity.com/tutorial/lesson-6-1-project-optimization-jp.md?language=ja&version=2022.1"
  - name: "2021.3"
    url: "https://learn.unity.com/tutorial/lesson-6-1-project-optimization-jp.md?language=ja&version=2021.3"
  - name: "2021.2"
    url: "https://learn.unity.com/tutorial/lesson-6-1-project-optimization-jp.md?language=ja&version=2021.2"
  - name: "2021.1"
    url: "https://learn.unity.com/tutorial/lesson-6-1-project-optimization-jp.md?language=ja&version=2021.1"
  - name: "2020.3"
    url: "https://learn.unity.com/tutorial/lesson-6-1-project-optimization-jp.md?language=ja&version=2020.3"
  - name: "2020.2"
    url: "https://learn.unity.com/tutorial/lesson-6-1-project-optimization-jp.md?language=ja&version=2020.2"
  - name: "2020.1"
    url: "https://learn.unity.com/tutorial/lesson-6-1-project-optimization-jp.md?language=ja&version=2020.1"
  - name: "2019.4"
    url: "https://learn.unity.com/tutorial/lesson-6-1-project-optimization-jp.md?language=ja&version=2019.4"
  - name: "2019.3"
    url: "https://learn.unity.com/tutorial/lesson-6-1-project-optimization-jp.md?language=ja&version=2019.3"
  - name: "2019.2"
    url: "https://learn.unity.com/tutorial/lesson-6-1-project-optimization-jp.md?language=ja&version=2019.2"
  - name: "2019.1"
    url: "https://learn.unity.com/tutorial/lesson-6-1-project-optimization-jp.md?language=ja&version=2019.1"
  - name: "2018.4"
    url: "https://learn.unity.com/tutorial/lesson-6-1-project-optimization-jp.md?language=ja&version=2018.4"
available_languages:
  - name: "en"
    url: "https://learn.unity.com/tutorial/lesson-6-1-project-optimization-1.md?language=en"
  - name: "es"
    url: "https://learn.unity.com/tutorial/leccion-6-1-optimizacion-del-proyecto.md?language=es"
  - name: "ja"
    url: "https://learn.unity.com/tutorial/lesson-6-1-project-optimization-jp.md?language=ja"
  - name: "ko"
    url: "https://learn.unity.com/tutorial/6-1gang-peurojegteu-coejeoghwa.md?language=ko"
last_updated: "2026-08-04T14:23:16.000Z"
---

# レッスン 6.1 - プロジェクトの最適化

モバイルやウェブ向けを含むプロジェクトのパフォーマンスを高める最適化テクニックをまとめて学びます。

**概要：**

このレッスンでは、プロジェクトを最適化してパフォーマンスを向上させるための様々なテクニックを学びます。ここで扱う小さなプロトタイププロジェクトでは大きな違いは感じられないかもしれませんが、大きなプロジェクトをエクスポートするとき、特にそのプロジェクトがモバイルやウェブ向けの場合は、パフォーマンスの向上に関するあらゆる要素が非常に重要になってきます。

**プロジェクトの成果物：**

いくつかのプロトタイププロジェクトがより最適化されます。これは皆さんが独自のプロジェクトに実装するためのサンプルとしても機能します。

## Materials

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

## 1. 変数の属性

> _このコースではこれまで、「public」と「private」の変数しか使いませんでしたが、他にも知っておくべき変数の属性が多数あります。_

[Video](https://connect-mediagw.unity.com/h1/20200728/videos/79495563-49ad-4e08-90ea-efa2e1794578_CWC_U6.L1.S1.mp4) ([Transcript (ja_jp)](https://connect-mediagw.unity.com/h1/20220506/1f14db65-328c-415d-a994-1ed7a16b28d5_213_Lesson_61_Variable_attributes.en.vtt))

1. Prototype 1 プロジェクトを開き、PlayerController.cs スクリプトを開きます。
2. private 属性の行の先頭に \[SerializeField\] を加えてから、Inspector で値を編集します。
3. FollowPlayer.cs で、\[SerializeField\] 属性を Vector3 offset 変数に追加します。
4. 「readonly」、「const」、「static」属性を適用すると、変数がインスペクター上に表示されなくなることを確認します。

![](https://connect-mediagw.unity.com/h1/20250609/learn/images/84d10322-9213-47be-b8c2-ebec5a100e26_image.png)

## 2. Unity のイベント関数

> _このコースではこれまで、デフォルトの Update() と Start() イベント関数しか使いませんでしたが、他にも状況に応じて使い分けるべきイベント関数があります。_

[Video](https://connect-mediagw.unity.com/h1/20200728/videos/93614135-bb1e-4c74-889b-c0b3ae504d02_CWC_U6.L1.S2.mp4) ([Transcript (ja_jp)](https://connect-mediagw.unity.com/h1/20220506/f8ec1ba2-2366-4c7b-9e10-45f053b285a4_214_Lesson_61_Unity_Event_Functions.en.vtt))

1. Main Camera を複製し、「Secondary Camera」と名前を変更し、メインカメラを無効にします。
2. Secondary Camera を一人称視点に再配置し、その位置に合うようにオフセット変数を編集します。
3. プロジェクトを実行して、まずぎこちなくカメラが動くところを見てみてください。
4. PlayerController.cs で「Update」を「FixedUpdate」に、FollowPlayer.cs で 「Update」を「LateUpdate」に変更し、再度テストします。
5. 両方のスクリプトの Start()関数を削除してから、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. オブジェクトプーリング

> _コースを通して、ゲームプレイ中にオブジェクトをインスタンス化したり破壊したりするプロトタイプをたくさん作ってきましたが、オブジェクトプーリングと呼ばれる、よりパフォーマンスの高い、効率的な方法があります。_

[Video](https://connect-mediagw.unity.com/h1/20200728/videos/4d9c8dc1-a249-42c3-8c72-dab6e597a8c4_CWC_U6.L1.S3.mp4) ([Transcript (ja_jp)](https://connect-mediagw.unity.com/h1/20220506/d941c844-1ec6-491a-9456-e7a8c788dff3_215_Lesson_61_Object_Pooling.en.vtt))

1. Prototype 2 を開き、バックアップを作成します。
2. Object Pooling unity パッケージをダウンロードして、シーンにインポートします。
3. PlayerController スクリプトをプレイヤーに再アタッチし、DetectCollisions スクリプトを動物のプレハブに再度アタッチします（食べ物のプレハブにはアタッチしません）。
4. ObjectPooler スクリプトを Spawn Manager にアタッチし、投射物を「Objects To Pool」変数にドラッグし、「Amount To Pool」を 20 に設定します。
5. プロジェクトを実行して、投射物の有効・無効がどのように切り替わるか観察します。

## 4. レッスンのまとめ

**新しい概念とスキル**

- 最適化
- シリアライズされたフィールド
- readonly / const / static / protected
- イベント関数
- FixedUpdate()、Update()、LateUpdate() の使い分け
- Awake() と Start() の使い分け
- オブジェクトプーリング
