Destroy 和 DestroyImmediate 使用区别
代码块
void Find()
{
GameObject mainObj = GameObject.Find("GameObject");
GameObject trs = mainObj.transform.Find("Test/Cube").gameObject;
Destroy(trs.gameObject); //打印结果 true 内存中还存在 没有被彻底销毁
Debug.LogWarning(trs != null);
}
void Find()
{
GameObject mainObj = GameObject.Find("GameObject");
GameObject trs = mainObj.transform.Find("Test/Cube").gameObject;
DestroyImmediate(trs.gameObject); //打印结果 false内存中不存在 已经被被彻底销毁
Debug.LogWarning(trs != null);
}