• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
4
Question by ben607070 · Mar 24, 2015 at 09:22 AM · build-error

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 alt text

error.png (35.1 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
4
Best Answer

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Symo7 · Apr 15, 2017 at 11:50 AM 1
Share

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..

avatar image
2

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 :)

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
4

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.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image elKarkayu · Apr 19, 2017 at 09:14 PM 0
Share

thanks man! the clue about demo scenes from the asset store saved my day!

avatar image emathew · Aug 16, 2017 at 06:56 PM 0
Share

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

avatar image CoderVinod · Oct 09, 2017 at 09:49 AM 0
Share

Thanks man

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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

Unity: Cannot find Android Device 3 Answers

Error building Player: CommandInvokationFailure: Failed to build apk. See the Console for details () 1 Answer

Editor throws TypeLoadException during build 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges