Open21
Unity小技集
![Fumo](https://res.cloudinary.com/zenn/image/fetch/s--L0k9fkby--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/dc806d7ff7.jpeg)
再生時にエディタの色を変える
- Edit > Preference > Colors > Playmode tint
![Fumo](https://res.cloudinary.com/zenn/image/fetch/s--L0k9fkby--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/dc806d7ff7.jpeg)
GameObject作成時の位置を0にする
- Edit > Preference > Scene View > Create Objects at Origin
- Create Objects with Constrained Proportions: Scaleを固定
![Fumo](https://res.cloudinary.com/zenn/image/fetch/s--L0k9fkby--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/dc806d7ff7.jpeg)
再生開始を早くする
- Edit > Project Settings > Editor > Enter Play Mode Options
- Reload Domain: スクリプトをリロード
- Reload Scene: シーンのオブジェクトをリロード
![Fumo](https://res.cloudinary.com/zenn/image/fetch/s--L0k9fkby--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/dc806d7ff7.jpeg)
コンパイルのタイミングを変える
- Edit > Preference > General > Script Changes While Playing
- Recompile After Finish Playing: 再生終了後にコンパイル
- Recompile And Continue Playing: コンパイル終了後に再生
- Stop Playing And Compile: 停止してコンパイル (オススメ)
![Fumo](https://res.cloudinary.com/zenn/image/fetch/s--L0k9fkby--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/dc806d7ff7.jpeg)
Cache Server
- 複数のエディタを運用している時にキャッシュを共有できて便利
- Unity Accelerator (Cache Server)
- Edit > Preference > Asset Pipeline > Unity Accelerator
![Fumo](https://res.cloudinary.com/zenn/image/fetch/s--L0k9fkby--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/dc806d7ff7.jpeg)
Scriptのテンプレートを編集する
- C:\Program Files\Unity\Hub\Editor\2022.3.11f1\Editor\Data\Resources\ScriptTemplates
- テンプレートをコピーして、ScriptTemplatesフォルダに入れる
![Fumo](https://res.cloudinary.com/zenn/image/fetch/s--L0k9fkby--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/dc806d7ff7.jpeg)
Assembly Definition
- Auto Referencedをオフにするとコンパイル範囲が限定される(速くなる)
- Root Namespaceを設定しておくと、自動でNameSpaceが付けられる
![Fumo](https://res.cloudinary.com/zenn/image/fetch/s--L0k9fkby--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/dc806d7ff7.jpeg)
WindowsDefenderの除外設定
- ビルド時が速くなる(不要なファイル走査を抑制)
- Windowsセキュリティ > ウィルスと脅威の防止 > ウィルスと脅威の防止の設定 > 除外の追加または削除
- Riderだと自動でやってくれる
![Fumo](https://res.cloudinary.com/zenn/image/fetch/s--L0k9fkby--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/dc806d7ff7.jpeg)
スナップ移動
- Ctrlを押しながら移動
- 回転、スケールもスナップ可
![Fumo](https://res.cloudinary.com/zenn/image/fetch/s--L0k9fkby--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/dc806d7ff7.jpeg)
オブジェクトにフォーカスを合わせる
- ヒエラルキー上のオブジェクトを選択してFキー
- またはダブルクリック
![Fumo](https://res.cloudinary.com/zenn/image/fetch/s--L0k9fkby--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/dc806d7ff7.jpeg)
階層を全表示
- Altキーを押しながら▼をクリック
![Fumo](https://res.cloudinary.com/zenn/image/fetch/s--L0k9fkby--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/dc806d7ff7.jpeg)
インスペクタをコピー、固定する
- コピー: Context Menu > Add Tab > Inspector
- 固定: 鍵アイコンをクリック
![Fumo](https://res.cloudinary.com/zenn/image/fetch/s--L0k9fkby--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/dc806d7ff7.jpeg)
コンポーネントの隠されたパラメータを見る
- Context Menu > Debug
![Fumo](https://res.cloudinary.com/zenn/image/fetch/s--L0k9fkby--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/dc806d7ff7.jpeg)
Project Windowの検索フィルター
![Fumo](https://res.cloudinary.com/zenn/image/fetch/s--L0k9fkby--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/dc806d7ff7.jpeg)
Unity Search
- Ctrl + k
![Fumo](https://res.cloudinary.com/zenn/image/fetch/s--L0k9fkby--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/dc806d7ff7.jpeg)
UI Toolkitのサンプル
- UI Toolkitの使用方法がすぐにわかるので便利
- Window > UI Toolkit > Samples
![Fumo](https://res.cloudinary.com/zenn/image/fetch/s--L0k9fkby--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/dc806d7ff7.jpeg)
Input Systemのデバッグ
- Window > Analytics > Input Debugger
![Fumo](https://res.cloudinary.com/zenn/image/fetch/s--L0k9fkby--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/dc806d7ff7.jpeg)
シーンビューのカメラ視点をヒエラルキー上のカメラに適用する
- ヒエラルキー上のカメラを選択
- GameObject > Align with View (Ctrl + Shift + F)
![Fumo](https://res.cloudinary.com/zenn/image/fetch/s--L0k9fkby--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/dc806d7ff7.jpeg)
UnityのProjectRootに置いて実行すると自動で必要なフォルダやgitignoreを生成するスクリプト