默认情况下已启用场景重新加载。这意味着,进入运行模式时,Unity 会销毁所有现有的场景游戏对象并从磁盘重新加载场景。Unity 执行此操作所需的时间随场景复杂性而增加,这意味着随着项目日益复杂,在按下 Play 按钮到场景完全载入 Editor 之间必须等待更长的时间。
禁用场景重新加载后,该过程将花费更少的时间。这使您可以更快地迭代项目的开发。Unity 不会从磁盘重新加载场景,而是仅重置场景的已修改内容。这样可避免卸载和重新加载场景所造成的时间和性能影响。Unity 仍然会调用相同的初始化函数(例如 OnEnable
、OnDisable
和 OnDestroy
),就像刚加载时一样。
务必注意,在禁用场景重新加载时,在 Editor 中启动应用程序所花费的时间不再表示在所构建的版本中启动的时间。因此,如果想对项目启动期间发生的情况进行准确调试或性能分析,应当启用场景重新加载以便更准确地表示所构建的版本中的真实加载时间和过程。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.