Cannot build player while editor is importing assets or compiling scripts

152455-unity-error.png

1 Like

Found a solution-
https://forum.unity.com/threads/i-cant-build-my-game.803667/

I had few scripts with “using Editor;” in them which were not part of an Editor assembly definition.
After refactoring and moving editor scripts to editor assembly definition and monobehaviour scripts to normal assembly definition, it worked.
@geekm

Did you create a custom UnityEditor script? If you did, you need to move it to another project that sits outside of your main project. For example, I had a PopupScriptableEditor.cs file in my main project “Assembly-CSharp”. I moved that script into my “Assembly-CSharp-Editor” project. The issue is that the “Player” or your main project is trying to build but there is an “Editor” script, that is also trying to be compiled at the same time and it’s not allowed.

158186-capture.png

Hi,
this thread is old, but I have something to add. I encoutered the same error and none of these tips worked for me. I have made a Post on Itch.io about what happened and how I fixed it, if you want the full story.
In short: Go to “C:\Users{YOUR USERNAME HERE}\AppData\Local\Unity\Editor” and look into the editor.log file after the failed build attempt. There is a more detailed failure description and in my case this helped me to find my error. If you can’t see the file, activate “Show hidden files” because it is hidden.

I don’t have a Using line for it, but I do use a method from it. It allows my exit method to handle being in the Unity editor. So I leave the code there, but disable it with a #if:

public void ExitGame()
{
	if (Application.isPlaying & !Application.isEditor)
		Application.Quit(); // We may return from this, but the program will terminate at the end of the frame
	#if false
	else
		UnityEditor.EditorApplication.isPlaying = false;    // Handle being in the editor, but set #if to true to use it
	#endif
}// ExitGame()

The cause of the issue is beacause you use UnityEditor in your script but this script is not in Editor folder.
To fix this issue, do this :

  1. Find all scripts containing “using UnityEditor”
  2. Move all these scripts to an Editor folder. Create this folder if necessary
    You can now generate your build.

I got the solution that unity tell you there is some scripts has errors you should delete it and delete the GI cash… that’s helped me

Once I removed this line, the problem went away:

using UnityEditorInternal;

Thank you for your help.

I’m having the same problem and I’ve tried anything that says ‘using UnityEditor’ so now the only things with it are the packages that are installed by default. I’ve used WebGL on some other projects and it’s worked fine and the only difference I can think of is that this one uses MLAPI. Does anyone know if this makes a difference?

I just had this happen. I’ve been building without error for a long time. I looked at the most recent scripts I was working on and found that to one a wacky using statement (something to do with Graphics)
had somehow been added to the top of the script along with the other using statements. It was nothing I had added intentionally. After I deleted it, I was able to build.

alt text

unity cannot build player while editor is importing assets or compiling scripts

Using blot
Using UnityEngine

If I delete this, it doesn’t work. How do I fix it?