概要
using UnityEngine; public class Example : MonoBehaviour { private void OnDestroy() { new GameObject(); } }
using UnityEngine; public class Example : MonoBehaviour { public GameObject m_prefab; private void OnDestroy() { Instantiate( m_prefab ); } }
上記のように OnDestroy で new GameObject()
や Instantiate( m_prefab )
で
ゲームオブジェクトを生成していると
Some objects were not cleaned up when closing the scene. (Did you spawn new GameObjects from OnDestroy?) The following scene GameObjects were found: XXXX
上記のエラーが発生します