【Unity】Can't destroy Transform component of 'XXXX'
概要
Can't destroy Transform component of 'XXXX'. If you want to destroy the game object, please call 'Destroy' on the game object instead. Destroying the transform component is not allowed.
上記のエラーは下記のように Transform を Destroy しようとした時に発生します
using UnityEngine; public class Example ; MonoBehaviour { public Transform target; private void Awake() { Destroy( target ); } }
ゲームオブジェクトを削除したい場合は
Transform ではなく GameObject を Destroy します
using UnityEngine; public class Example ; MonoBehaviour { public Transform target; private void Awake() { Destroy( target.gameObject ); } }