Skip to content

Instantly share code, notes, and snippets.

@MateSteinforth
Created November 23, 2022 09:17
Show Gist options
  • Select an option

  • Save MateSteinforth/71c7cb037ab56896a70be5a6f05137a2 to your computer and use it in GitHub Desktop.

Select an option

Save MateSteinforth/71c7cb037ab56896a70be5a6f05137a2 to your computer and use it in GitHub Desktop.
// Remember to put the script you choose inside a folder called Editor inside your Assets folder.
using UnityEditor;
public static class CompileBeforePlay
{
[InitializeOnLoadMethod]
public static void Initialize()
{
if (EditorApplication.isPlaying) return;
EditorApplication.update += Update;
}
private static void Update()
{
if (EditorApplication.isPlayingOrWillChangePlaymode && !EditorApplication.isPlaying)
{
AssetDatabase.Refresh();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment