How to Fix “Cannot Build Player” Issue in Unity

Cannot build player while editor is importing assets or compiling scripts

The build error is :

If you want to build your project , and you get this error : "Cannot build player while editor is importing assets or compiling scripts."

Cannot build player while editor is importing assets or compiling scripts

The cause of the error is that the script uses the UnityEditor function in the script, but it is not in the Editor folder!

Resolution steps

1. Find the scripts that use the "using UnityEditor;" library.
2. Place the script in the Editor folder.
3. Build.

Video Tutorial for how to Fix issue : Cannot build player while editor is importing assets or compiling scripts


Additional suggestion:

The error "Cannot build player while editor is importing assets or compiling scripts" usually occurs when Unity is still importing or compiling assets in the background. This can cause conflicts with building the player. Try the next actions to fix the problem::

  1. Wait until Unity is finished importing and compiling assets. If it's taking a long time, you can try cancelling the import/compilation process.

  2. Check if there are any errors or warnings in the Console window. This can sometimes indicate a problem with a specific asset that is causing the build to fail.

  3. Close and re-open the Unity Editor. This can often resolve any temporary issues that may be causing the build to fail.

  4. Try building a smaller version of your project first to see if the problem persists. If it doesn't, you can try gradually adding assets back into the project to identify which one is causing the issue.

  5. If you're still encountering the issue, you can try cleaning the project and deleting the Library folder. This will force Unity to re-import all assets and rebuild the project from scratch, which can sometimes resolve the issue.

If none of these steps resolve the issue, you may need to try updating Unity, or contacting Unity Support for further assistance.


tag : error building player because script class layout is incompatible between the editor and the player,error building player because scripts have compile errors in the editor,unityeditor.buildplayerwindow+buildmethodexception: 2 errors,unity can t build,the type or namespace name build does not exist in the namespace 'unityeditor,buildfailedexception incremental player build failed,unity build the type or namespace name editor could not be found,unitybuild error.

 ,unity can t build,buildfailedexception incremental player build failed,unity build the type or namespace name editor could not be found,unitybuild error,error building player because scripts have compile errors in the editor,error building player because script class layout is incompatible between the editor and the player