Editor Compile in Background?

Is there any way to have the editor recompile the project in the background on file change in an external IDE?

Currently, I have to focus on the editor to kick off a recompilation.

This would really help coding workflow.

You can certainly compile from a command line Unity - Manual: Command-line arguments

1 Like

Interesting, you’re saying that I can access the running editor instance via command line and trigger an editor recompile? I don’t want to do a full build. I just want to code in my external IDE and then have the editor already building or ideally ready to run when I tab back over to it.

Rider/Resharper’s Unity plugin has a toggle for “automatically refresh assets in Unity”, which does what you’re asking. Maybe VS’ plugin has something similar?

1 Like

No, I was referring to a command line build.

saw this while ago, havent tested yet but sounds useful,

“You can start compiling without having to return focus to the Unity editor after changing the script”
https://github.com/baba-s/unity-compile-in-background

1 Like

Yeah, I’d noticed that as well. Looks like it launches a monitoring program that polls for file metadata updates (e.g. time updated) and then kicks off an asset refresh. Seems like a reasonable approach. I was just a bit nervous about running a pretty unknown quantity like this. I’m also on osx for now, and it utilizes an exe for the monitoring program. Could potentially be rebuilt for osx.

Maybe I’ll roll my own that uses an explicit system event sent from Visual Studio vs polling for file changes if I get around to it.

It seems VS2019 + Unity 2019.1 do that out of box

6 Likes

That’s great, however, it binds you to to Visual Studio, some developers are on Visual Studio Code or other IDEs that are less bloated, so they cannot enjoy this feature. Also, it will not work for other types of assets that you edit in another software.

However, I have a solution to this that I will share, once my tests are complete.

3 Likes

Haha. Came here because I just installed VS 2019 Community (but with Unity 2018.3.x) and now I want it to STOP compiling in background. (I don’t want it to start every time I save a file!). Any ideas?

3 Likes

Exact same thing here. I need it to stop and am considering going back to 2017. It makes editing code so incredibly sluggish when it’s constantly compiling and recompiling and re-recompiling. Is there any hack to disable it before we (hopefully) get an option to do so?

1 Like

Same here! I’ve just created a new folder in the Solution window and it vanished instantly (stopped being included) before I had time to insert any scripts there.

@charlie_sbg @laessnb I might have just found a solution! in Visual Studio go to Tools → Options

It seems that it helped :slight_smile: What a relief :slight_smile:

12 Likes

I actually love the compilation in the background, unfortunately very often, it doesn’t want to stay in the background and the editor comes to the top, stopping me from writing the code. This is very annoying - is there a way to prevent the editor from popping up?

2 Likes

This feature does not work properly for me. It keep reloading the project in Visual Studio, freezing VS for good 5-10 seconds.

1 Like

If you are using visual studio you can manually recompile in it and unity doesn’t need to recompile again when you focus to editor. You just need to use ctrl+shift+b instead of ctrl+s :slight_smile:

2 Likes

Thank you, exactly what the team needed.

1 Like

@JeffDUnity3D is there any existing method or plans to enable background compiling for VS Code?
Can the same method being used by Rider and the complete Visual Studio be used by VS Code?

3 Likes

Seconded!

That would be a dream!