I’m sharing here a nice solution I came up with while thinking about how to reduce painful iteration time. If your script change iteration time is less than 6 secs you are probably better off without this but you can try.
Make a backup of your project and try the following on the copy or original:
- Put your big dependencies/plugins in separate asmdefs
- Add define constraints to those asmdefs (e.g FEATURE_X for an asmdef named Feature X) (https://docs.unity3d.com/2020.3/Documentation/Manual/class-AssemblyDefinitionImporter.html#define-constraints)
- Disable the ones that aren’t vital when working on certain features for example by adding a “!” character next to the scripting define symbol e.g FEATURE_X! (ProjectSettings > Player: Unity - Manual: Custom scripting symbols).
- To deal with the errors caused by disabling a non-vital dependency wrap the coupling code parts with
#if FEATURE_X
...
#endif
- Done.
To renable an asmdef you simply have to remove the “!” or any character you chose next to the define if you followed my method.
I searched a lot on the net and yet not a single person gave an accurate working solution to this problem or thought about this one and tbh I’m baffled considering this issue has existed for more than 2 years and not even the UT staff suggested it to my knowledge (simply putting code in asmdefs alone doesn’t help) and yet in less than 2 days I discovered define constraints’ usefulness & came up with this neat lil trick once I finished measuring each plugin’s impact.
Note: not all dependencies/assemblies have a significant reload time impact, you might wanna measure to choose which ones are worth the trouble to disable if you have a significant coupling to particular ones in your code.
Make automatic backups of your project’s main data that’s stored in components/scriptable objects that are subject to being disabled by this process in case of data loss though it only happened to me once and can’t say whether it was due to a crash, this trick or something else.
In my case I was able to reduce the reload time by ~2.3 secs from ~9.6s down to ~7.34s by literally disabling about all but 2 lightweight plugins and 1 for improved hierarchy that although has an impact is still worth keeping for quality of life purposes.
I wish I could reduce it further but you may have bigger benefits because I had already reduced the reload from 17 secs previously to ~9.6s by straight up removing several plugins & packages from the project though now that I discovery this trick I’ll reimport then and use this instead.
Another tip is reducing enter/exit playmode times by doing your iterations on a minimalistic scene, in my case it takes < 1 sec to enter playmode that way.
Compare ~17s script change time + ~15s for enter play mode + ~2s for exit to ~7.5s + < 1s + < 1s for iteration time.
If I make any other beneficial discovery I’ll make another post and link it here cuz this one already gotten long.
Hope this helps, I know for fact it works because disabling impactful asmdefs prevents their .dll assemblies from being generated in your Library/Script Assemblies
thus their reload time but whether you can apply it for certain assemblies depends on your level of coupling to them.
Make sure to share this link to reduce this huge daily pain for everyone using Unity whenever this topic is brought up until UT finally releases a proper practical solution 2+ years later, hopefully sooner**.**