GetComponent()
タイトルのように入力したのにnullが返ってくる人へ
using UnityEngine.U2Dから
using UnityEngine.Experimental.Rendering.Universal;
に変更したら参照できるようなりました
github copilotが出したコードはずっと間違えていた。
https://discussions.unity.com/t/unable-to-grab-a-reference-to-a-pixel-perfect-camera-component/916507
追記
Unity6.x以降から、参照エラーが発生しました。
https://discussions.unity.com/t/error-with-pixelperfectcamera-after-upgrading-to-unity-6-in-urp-2d-project/1538791/6
Package Managerから2D Pixel Perfectをインストールすることで解決できます。
Namespace: UnityEngine.Rendering.Universal
Assembly: Unity.RenderPipelines.Universal.2D.Runtime.dll
スクリプトが asmdef 配下ならDLLファイルを、追加してください