【Unity】GetComponent と TryGetComponent の違い

GetComponent の場合 using UnityEngine; public class Example : MonoBehaviour { private void Update() { var result = GetComponent<Rigidbody>(); if ( result != null ) { } } } アタッチされていないコンポーネントを GetComponent すると Unity エディタ上でのみ GC Alloc が発生します (ビルドしたアプリケーションでは GC </rigidbody>…