Skip to content

Instantly share code, notes, and snippets.

@jfranmora
Last active June 25, 2020 08:47
Show Gist options
  • Save jfranmora/971d750658675c0fb9b14a0840a7c3d2 to your computer and use it in GitHub Desktop.
Save jfranmora/971d750658675c0fb9b14a0840a7c3d2 to your computer and use it in GitHub Desktop.
Editor extension, automatically triggers a compilation when entering play mode.
using UnityEditor;
namespace JfranMora
{
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