Force script recompilation

Hello everybody. Our project has a settings menu that changes several compile defines via the gmcs.rsp and smcs.rsp files. Is there any way to force unity to recompile all the scripts when these files change? Otherwise users change settings and wonder why those changes aren’t reflected when they run the game.

I have a system that does something very similar. This is how I force a recompile:

  AssetDatabase.StartAssetEditing();
  string[] allAssetPaths = AssetDatabase.GetAllAssetPaths();
  foreach (string assetPath in allAssetPaths)
  {
    MonoScript script = AssetDatabase.LoadAssetAtPath(assetPath, typeof(MonoScript)) as MonoScript;
    if (script != null)
    {
      AssetDatabase.ImportAsset(assetPath);
    }
  }
  AssetDatabase.StopAssetEditing();

I would be interested to know if there is a simpler/less expensive way to do it.

I think I did something similar to what you did there, but you can simply break after the first script you touch, since all you really need to do is touch one script to trigger unity to recompile. Runs much faster than touching all the scripts.