- Home /
unity error building player because scripts had compiler errors
hello i been using unity pro for sometime now but i have never came across a error like this. because of this error i'm unable to build my game and finish it :( please help from Ben
Answer by CHPedersen · Mar 24, 2015 at 09:25 AM
What this is telling you is that you can't use editor code in your builds. Which, when you think about it, makes perfect sense. "UnityEditor" is the namespace for all the code that is executed in the Editor. It isn't part of the engine ("UnityEngine").
Remove code from your game that uses components that are only available in the Editor. This could be file dialogs, for example.
This is quite true, however I'm getting the issue with a custom editor which I'm not using at runtime (the editor code is not used in the scene). Furthermore if I try and build the project, it fails and then the project won't run in the editor any more until I restart Unity - this seems to be a bug. So is the answer that to be able to build you need to copy your project, then delete all editor code (even from the Assets section?). Not very practical..
Answer by jayant_vishwakarma · Oct 18, 2016 at 06:41 AM
it Seems that you are using package from asset store or any other place it happens because external packages contains demo scene you just need to delete all the script that are using UnityEditor just click on error message and unity will redirect you to the script look at the top of the script if there is statement like "using UnityEditor" delete that script and error will gone if it is not gone look there is another any script that contains "using UnityEditor" delete that.
thanks man! the clue about demo scenes from the asset store saved my day!
Dude. Thank you. Ive been struggling with this for a few hours. I imported those demos accidentally, but I deleted it all now. It worked!! Haha
Answer by jonasprb · Sep 26, 2017 at 03:55 PM
Don't know it's already mentioned somewhere, but after looking through 100 revisions to find the Editor code responsible for "Error building Player because scripts had compiler errors" again I had to do something to remember the following:
open unity.csproj with a text editor (project file is locked inside VS)
delete all occurrences of UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_WIN;
reload solution, compile and see compile errors with file/line information :)
Your answer
Follow this Question
Related Questions
Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers
How can I stop the variable values reverting to its default values after being built? 1 Answer
Why do I get so many errors when I switch to ARM64? 0 Answers
Final Build problem 0 Answers
Roll a Ball can't pick up game objects in the build? 0 Answers