Faster Unity Script Changes

Anthony Topper
4 min readJan 25, 2024

Any significantly complex software editor will have its share of frustrations. For Unity, that little window that says “Hold On …” can be chief among them.

Unity’s script reload process has several steps, making diagnosis of slowdowns difficult. “Completing Domain” is one of them.

There are several steps between making a code change and having it running. Making it sometimes tricky to diagnos what’s taking so long. Adding to that is each step can casually go by slightly different name: recompile, compile time, domain reloads, “Complete Domain”, reload script assemblies, etc.

Creators under the “Made with Unity” umbrella, like me, want as short a feedback cycle as possible. I want to change my code and have it running right away please.

I’ve curated somethings that can speed up this process when it starts getting slow or freezing altogether. Some of these can break your project; make a good backup before trying them yourself. Your mileage may vary. More details further after the list.

  • Unity Editor
    Consider updating your current editor version.
  • External Script Editor
    Whether it’s Visual Studio, JetBrains Rider, or something else, getting it up to date may help.
  • Package Manager
    Keep your packages in order.
  • Library Cache
    Clear your cache and let Unity rebuild it.
  • Better Computer Hardware
  • Assembly Definitions
    Organize your code better.
  • Preferences and Settings
    Many settings can affect script iterations: Domain Reload, Burst Compilation, Auto Refresh, etc.

Update your Unity Editor

It’s often best to be on the latest version of the Unity Editor for whatever major version you are on. Sometimes an upgrade will help but often not or only minorly. However, this at least helps rule something out.
Back up your project before upgrading your editor version.

Update your External Script Editor

Make sure your “External Script Editor” is up to date. And the Unity plugin or extension, if any, is up to date as well. In my case, this is Visual Studio and the Visual Studio Tools for Unity extension.

Keep Package Manager Tidy

One of your packages could be the culprit. Keep your installed packages tidy by removing things you don’t need. Updating packages that have newer versions may help. Packages can use Unity features like InitializeOnLoad, which can be triggered during Unity’s reloading process.

I’ve found this to be risky as well; read the changelogs and back up your project.

Clear and Rebuild your Library Cache

Inside your Unity project is a “Library” folder, at least on Windows that’s what it’s called. The last time I deleted mine it contained 82K files. After deleting this directory, open your project; it will take much longer to open than usual. That’s because Unity is rebuilding your library cache.

This took my project from around 90K files down to 59K files.

Use Better Computer Hardware

Lots of options to consider: a more powerful GPU, CPU, or memory.

If you have the resources:

  • Ditch the laptop and move to a desktop.

Or, even more extreme:

  • Move to a workstation platform for more memory channels and more PCI lanes, which can allow for things like m.2 RAID0. (I love my super fast hard drive.)

Use Assembly Definitions

Separate code using Assembly Definitions.

This is also just a good general practice as it forces you to be more thoughtful about what code depends on what other code. And if you ever make more than one Unity game you can consider how to reuse code between projects.

For more one this, the developer behind a game called Tales of Kulplex wrote up a devlog that dives into this topic deeper: Tales of Kulplex, Devlog #6 — Attempting to Decrease Compile Times in Unity

Check Preferences and Settings

The following setting and preferences are known to affect script reloading.

Other Benefits

Many of the tactics above have other benefits. I was struggling with Unity scene saves taking a long time. Recently, I had that issue go away by working through the steps above.

About

If you found benefits from this article please consider following my game’s development at twitter.com/madjoystudio. Check out my game development origin story: The Adventure Begins: Founding a Game Studio — Part 1

Appendix

Other Options

This came up in my research but I have yet to try it.

Unity Forums

Unity Issue Tracker

Stackoverflow

Reddit

--

--

Anthony Topper

Founder: Mad Joy Studio. Former design leader: Walmart, ebay. Podcast host: The Secret Cabal. CrossFitter. https://www.linkedin.com/in/tonytopper