Skip to content

Instantly share code, notes, and snippets.

@instance-id
Created November 24, 2021 16:21
Show Gist options
  • Save instance-id/a23b3d7b6674588df7ff17eeb7844bfb to your computer and use it in GitHub Desktop.
Save instance-id/a23b3d7b6674588df7ff17eeb7844bfb to your computer and use it in GitHub Desktop.
Lock compilation so you can move folders and items without compiling on each one
using UnityEngine;
using UnityEditor;
// -- Place in Editor Folder ------------
namespace instance.id.Extensions.Editors
{
/// <summary>
/// This editor utility can lock/unlock unity script compile from menu item.
/// See more https://raspberly.hateblo.jp/entry/InvalidateUnityCompile
/// </summary>
public static class CompileLocker
{
[MenuItem("Tools/instance.id/Compile/Lock", false, 1)]
static void Lock()
{
var menuPath = "Tools/instance.id/Compile/Lock";
var isLocked = Menu.GetChecked(menuPath);
if (isLocked)
{
Debug.Log("Compile Unlocked");
EditorApplication.UnlockReloadAssemblies();
Menu.SetChecked(menuPath, false);
}
else
{
Debug.Log("Compile Locked");
EditorApplication.LockReloadAssemblies();
Menu.SetChecked(menuPath, true);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment