0%

Unity Destroy和DestroyImmediate的区别

Destroy

Destroy是异步销毁,一般在下一帧就销毁了,不会影响主线程的运行。

DestroyImmediate

DestroyImmediate是立即销毁,立即释放资源,做这个操作的时候,会消耗很多时间的,影响主线程运行

官方推荐使用Destroy代替DestroyImmediate

官方文档里说:

Destroy is always delayed (but executed within the same frame).

Actual object destruction is always delayed until after the current Update loop, but will always be done before rendering.

Destroy应该是当前帧 Update之后,渲染之前销毁对象