Unity manually compiles the Reload script to reduce waiting time

Unity manually compiles the Reload script

This is a custom reload domain tool to speed up the workflow and reduce waiting. The test version is Unity2021, theoretically speaking, it can be above 2020.

Script address: UnityManualReload (github.com)

Problems encountered in Unity

In the unity workflow,修改脚本->编译脚本->reload domain(重载域)-> 进入play

The compilation can be accelerated by distinguishing the assembly, but the reload domain is very slow. The reload domain must be reloaded after each compilation, and the reload domain will also be reloaded before entering the playback.

Example:

0

Writing programs often Ctrl+s, once saved, will recompile, and then trigger reload. Sometimes we will return to the Unity editor, just view the scene, and do not want to reload, which will make us wait for a long time.

Unity has an Enter Play Mode Setting configurable to enter the running mode - Unity Manual

image-20221105210343196

Disabling Reload Domaincan quickly enter the playback mode. But every time the script is modified, it will still be reloaded. Also, for 静态数据如果没有重新reload 还是会保持之前的数据( it is recommended not to disable, it is really tricky ) for details: https://docs.unity.cn/cn/2021.3/Manual /DomainReloading.html

Of course, some can be manually refreshed by disabling Auto refresh, using , but if other resources such as pictures are imported, they must be refreshed.ctrl+r

So it is still the most reliable to manually reload

How to solve frequent reload

What we have to do is, after adding a new script or modifying the script, after confirming that it is correct, we are reloading, and entering the play mode, if the domain has been reloaded, it will not reload twice

Unity provides two APIs EditorApplication.LockReloadAssemblies();, EditorApplication.UnlockReloadAssemblies();one for locking and one for unlocking.

Working together Enter Play Mode Settingcan greatly reduce time.

Renderings:

111

Instructions

After the script is imported into the Editor folder, click on the menu bar Tools->Tools/开启手动Reload Domainand press it when reload is required Ctrl+t.

It should be noted that because the script is disabled reload domain, if there is no manual reload before running, the static data will not be cleared, which may cause some problems

New Improved 08 Nov 2022 15:32:33

  • Every time before entering the play mode, it will check whether it needs to reload. If it has been reloaded, it will not be used. If not, it will be automatically reloaded, so as to ensure the correctness of the data every time.

reference

Unity turns off script compilation - Zhihu (zhihu.com)

Guess you like

Origin blog.csdn.net/K20132014/article/details/127709742