Automatically save scripts when returning to Unity from Visual Studio

I’d like to know how to get Unity to recompile scripts automatically (when editing is done from Visual Studio or other editors and switching back to Unity). I always forget to save the script and the play button in unity doesn’t save the script for me.

I know VS has an autosave feature:

However, I only want the script to be saved and recompiled when unity gets focus (the front active window).

1 Like

Ctrl+s, you can’t expect anything to do your job for you. :slight_smile:

What’s the issue with the script being saved when you bring any other app but Unity to the foreground?

We have once solved that problem (or at least a problem like that) in Rider.
If saving is delayed a bit, Unity would not detect the changes. Try to move focus there and back couple of times and see, if it helps Unity to detect the changes.

There’s nothing issue with it. It’s just that I think this solution should be done by Unity or VS Unity Tool.

What’s wrong with saving your work before going back to Unity? :lol: