Play Mode is at the core of what makes Unity fun to work with. But as your projects get more complex, it can take a while to get started. The faster you can enter and exit Play Mode, the faster you can make and test changes. That’s why we’re introducing Configurable Enter Play Mode in Unity 2019.3 beta as an experimental feature.
播放模式是使Unity有趣工作的核心。 但是,随着您的项目变得越来越复杂,可能要花一些时间才能开始。 进入和退出“播放模式”的速度越快,进行和测试更改的速度就越快。 这就是为什么我们在Unity 2019.3 beta中引入可配置进入播放模式作为实验功能的原因。
Currently, when you enter Play Mode in the Editor, Unity does two things: it resets the scripting states (Domain Reload) and reloads the Scene. This takes time, and the more complex your project gets, the longer you need to wait to test out new changes in Play Mode. Starting with Unity 2019.3 beta, however, you’ll have an option to disable either, or both, of the “Domain Reload” and “Scene Reload” actions.
当前,当您在编辑器中进入播放模式时,Unity会执行两件事:重置脚本状态(域重新加载)并重新加载场景。 这会花费时间,并且项目变得越复杂,等待测试Play模式中的新更改所需的时间就越长。 但是,从Unity 2019.3 beta开始,您可以选择禁用“域重新加载”和“场景重新加载”操作中的一个或两个。
Based on our test results, this can save you up to 50-90% of waiting time, depending on your project.
根据我们的测试结果,这可以节省多达50-90%的等待时间,具体取决于您的项目。

We’ve tested Configurable Enter Play Mode with an AA production title, our FPS Sample, Megacity, and an empty project. The graph represents the seconds it took for the Editor to enter Play Mode, smaller numbers are better.
我们已经使用AA制作标题,FPS示例,Megacity和一个空项目测试了可配置的进入播放模式。 该图表示编辑器进入播放模式所花费的秒数,数字越小越好。
When you enable Enter Play Mode Options in File > Project Settings > Editor, you’ll see that the options to reload Domain and reload Scene become available. Check out How to configure Play Mode in the documentation for more details.
在“ 文件” >“ 项目设置” >“ 编辑器 ”中 启用“ 输入播放模式选项 ”后 , 您将看到 重新加载“域”和“重新加载场景”的选项可用。 看看 如何配置播放模式 的文档中了解更多详情。

These options allow you to disable Domain and/or Scene reloading from the Enter Play Mode process when there are no code changes. You can also access this feature through an API and a Callback if you want to reset the game state before entering Play Mode.
这些选项使您可以在没有代码更改的情况下,从Enter Play模式进程中禁用“域和/或场景重新加载”。 如果要在进入“播放模式”之前重置游戏状态, 还可以通过 API和“回调” 访问此功能 。
The diagram below shows the Enter Play Mode process before and after you disable Reload Domain and Reload Scene:
下图显示了禁用重载域和重载场景之前和之后的进入播放模式过程:

See more details on the processes that Unity goes through when entering Play Mode in the documentation.
请参阅 文档 中 有关 进入播放模式时Unity经历的过程的更多详细信息 。
Note that this feature is currently experimental and not all Unity packages are validated to work with disabled Domain and Scene Reloading. Please let us know on the forum if you run into any issues!
请注意,此功能目前处于试验阶段,并非所有Unity软件包都经过验证可与禁用的“域和场景重新加载”一起使用。 如果您遇到任何问题, 请在 论坛 上告诉我们 !
禁用域重新加载后如何正确修改脚本 (How to modify your scripts correctly when you’ve disabled Domain Reload)
As you can see, avoiding Domain reload is very simple, but it comes at a cost. You need to make adjustments to static fields and static event handlers in your scripts to ensure your scripting states reset correctly when Play Mode is entered.
如您所见,避免域重新加载非常简单,但这要付出一定的代价。 您需要对脚本中的静态字段和静态事件处理程序进行调整,以确保在进入“播放模式”时正确重置脚本状态。
The following code example has a counter which goes up when the player presses the Jump button. When Domain Reloading is enabled, the counter automatically resets to zero when entering Play Mode. After you disable Domain Reloading, the counter doesn’t reset; it keeps its value in and out of Play Mode. This means that on the second run of your Project in the Editor, the counter might not be at zero if it changed in the previous run.
下面的代码示例具有一个计数器,当玩家按下“跳转”按钮时,该计数器就会上升。 启用“域重装”后,进入“播放模式”时,计数器会自动重置为零。 禁用域重新加载后,计数器不会重置; 它会保持其值在“播放模式”中和不在播放模式中。 这意味着在编辑器中项目的第二次运行中,如果计数器在上一次运行中发生更改,则计数器可能不会为零。
1
2
3
4
5
6
7
|