Unity Re-compiles on Play

When pressing the Play button in the Unity Editor a recompile is triggered. Any idea why this might happen?

Things I have considered causing the issue:

  • An editor script that I have that triggers a project save on run
  • Removing it does not prevent the issues, beside recompile would happen despite having no modifications to save
  • Version control system I use (Perforce)
  • Does not cause issues on my other computer, so its unlikely
  • An alternative editor script causing a re-import
  • I have done a search for AssetDatabase.ImportAsset and AssetDatabase.Refresh but have found nothing

I have created an empty project trying to reproduce the issue however in a new project I cannot get it to occur.

After further research I found out the offending code was in UnityAdsBuildProcessor. OnPostprocessScene would get called and for some reason the following code triggered a recompile.

As for why it happens on one computer and not the other: Its possible its because my main computer has Unity pro setup on it and my secondary computer that I don’t use often only runs the free version.

[PostProcessScene]
public static void OnPostprocessScene()
{
    AdvertisementSettings.enabled = true;
    AdvertisementSettings.initializeOnStartup = false;
}