I am getting the following error when trying to build for PC/Windows:
UnityEditor.BuildPlayerWindow+BuildMethodException: Error building Player because scripts have compile errors in the editor at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x00234] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:190 at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x0007f] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:96 UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
I have googled this issue, and the answers I found were:
Re-import all assets
Remove the .sln files (Visual Studio solution files) from your project
Change the build folder to outside the project
Remove the Plugins folder from the Assets folder
I did 1-3 and the problem remains. #4 doesnât make since, because I have plugins which are required in that folder.
The project is compiling and running inside Unity, but it just wonât build.
My Unity version is 2018.3.4f1, if that helpsâŚ
Can you please advice? This is extremely frustrating and I am fighting this over 2 days now
Run a search through your entire codebase for âUnityEditorâ. Any script that references âUnityEditorâ must either be inside a folder called âEditorâ, or must have all references of âUnityEditorâ wrapped in pre-compile flags to exclude them from a build. By pre-compile flag, I mean something like â#if UNITY_EDITORâ / â#endifâ.
The reason this is suggested is because some plugins may have editor-only code.
I found that the SteamVR asset I am using has many references to UnityEditor, but I donât think modifying them is a good idea.
However, I did found one reference in my code, and removed it (temporarily), and surprisingly it solved the problem. How come SteamVR can use UnityEditor in their code and it doesnât cause build errors?
Any script inside of an âEditorâ folder does not get included in a build. Any code between a â#if UNITY_EDITORâ and â#endifâ also does not get included in a build. Code that is not included in a build cannot cause errors during a build or outside of the editor.
The meta files of some plugins may exclude the associated plugin from certain types of builds via platform settings.
Hi to everyone.
I am just starting with unity for VR on a 3D model for the office i work for .I tried to buid up a the project and ger similar issues as the other person before. I just don really get what you meant in the comments as I dont really know much about the program and neither know how to code or similiar
The following are the errors that show up. I hope you can help me out.
Cheers
Library\PackageCache\com.unity.visualscripting@1.8.0\Runtime\VisualScripting.Core\Utilities\RuntimeVSUsageUtility.cs(18,13): error CS0103: The name âSavedVariablesâ does not exist in the current context
Library\PackageCache\com.unity.visualscripting@1.8.0\Runtime\VisualScripting.Core\Utilities\RuntimeVSUsageUtility.cs(20,13): error CS0103: The name âApplicationVariablesâ does not exist in the current context
Error building Player because scripts have compile errors in the editor
Build completed with a result of âFailedâ in 0 seconds (473 ms)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
UnityEditor.BuildPlayerWindow+BuildMethodException: Error building Player because scripts have compile errors in the editor at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002da] in <42a64fd733d9417da1ea3a757ad9a96d>:0
First, make a blank project with a single blank scene and prove that it builds successfully.
If the blank project does NOT build, go fix your Unity installation or your other tools, such as Android SDK, NDK, JDK, etc. It may even be necessary to change to a different version of Unity3D. It is generally best to stay with LTS versions of Unity3D.
Until you can build a blank project to the target platform, donât fiddle with anything else.
Once you can build a blank project, now bisect the problem by bringing over parts of your current project and building it one subsystem at a time, perhaps stubbing things out that might trigger compiler errors.
Most often things that prevent building are third-party libraries such as Firebase.
Once you identify the subsystem, go to the documentation for it and make sure you are doing it correctly.
It may also be helpful to work through a tutorial or two for whatever subsystem is making the build fail.
Android build not building:
Recently (circa July 2022) there have been reports of Unityâs installer failing to install the Android Tools.
Here was how I brought up Unity2020.3.41 and the Android SDK 31 on October 30, 2022: