Any version of Unity I tried, really, but for the sake of reference lets say 2019.2.10f1
I create a new project. I change nothing. I try to build (fails for any target, but lets say PC, Mac and Linux Standalone). I get this:
Error building Player because scripts have compile errors in the editor.
Error log isn’t really helpful, even when I changed it to “full”. I’m not sure what one can get from this, it just says there’s an error but doesn’t specify it:
UnityEditor.BuildPlayerWindow+BuildMethodException: Error building Player because scripts have compile errors in the editor
at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x00242] 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:95
0x0000000142A1260C (Unity) StackWalker::GetCurrentCallstack
0x0000000142A15AE1 (Unity) StackWalker::ShowCallstack
0x00000001412AE835 (Unity) GetStacktrace
0x00000001435C93AD (Unity) DebugStringToFile
0x0000000142A46A94 (Unity) DebugLogHandler_CUSTOM_Internal_Log
0x000000003200FDDB (Mono JIT Code) (wrapper managed-to-native) UnityEngine.DebugLogHandler:Internal_Log (UnityEngine.LogType,UnityEngine.LogOption,string,UnityEngine.Object)
0x000000003200FCAB (Mono JIT Code) [DebugLogHandler.cs:10] UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[ ])
0x000000003201FA25 (Mono JIT Code) [Logger.cs:61] UnityEngine.Logger:Log (UnityEngine.LogType,object)
0x000000003201F6B9 (Mono JIT Code) [Debug.bindings.cs:127] UnityEngine.Debug:LogError (object)
0x0000000002D8DCDB (Mono JIT Code) [BuildPlayerWindowBuildMethods.cs:101] UnityEditor.BuildPlayerWindow:CallBuildMethods (bool,UnityEditor.BuildOptions)
0x0000000002D88CF3 (Mono JIT Code) [BuildPlayerWindow.cs:897] UnityEditor.BuildPlayerWindow:GUIBuildButtons (UnityEditor.Modules.IBuildWindowExtension,bool,bool,bool,UnityEditor.Build.BuildPlatform)
0x000000003197A203 (Mono JIT Code) [BuildPlayerWindow.cs:788] UnityEditor.BuildPlayerWindow:ShowBuildTargetSettings ()
0x000000003196A92B (Mono JIT Code) [BuildPlayerWindow.cs:359] UnityEditor.BuildPlayerWindow:OnGUI ()
0x0000000017BA9E48 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
0x000007FEDD8EC010 (mono-2.0-bdwgc) [mini-runtime.c:2809] mono_jit_runtime_invoke
0x000007FEDD872122 (mono-2.0-bdwgc) [object.c:2921] do_runtime_invoke
0x000007FEDD87B2F2 (mono-2.0-bdwgc) [object.c:3073] mono_runtime_invoke_checked
0x000007FEDD87BA89 (mono-2.0-bdwgc) [object.c:5264] mono_runtime_try_invoke_array
0x000007FEDD87B286 (mono-2.0-bdwgc) [object.c:5142] mono_runtime_invoke_array_checked
0x000007FEDD8202B4 (mono-2.0-bdwgc) [icall.c:3358] ves_icall_InternalInvoke
0x00000000156C8126 (Mono JIT Code) (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[ ],System.Exception&)
0x00000000156C66DB (Mono JIT Code) System.Reflection.MonoMethod:Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[ ],System.Globalization.CultureInfo)
0x00000000156C639F (Mono JIT Code) System.Reflection.MethodBase:Invoke (object,object[ ])
0x0000000029AF7B33 (Mono JIT Code) [HostView.cs:359] UnityEditor.HostView:Invoke (string,object)
0x0000000029AF7993 (Mono JIT Code) [HostView.cs:354] UnityEditor.HostView:Invoke (string)
0x000000003196960B (Mono JIT Code) [HostView.cs:139] UnityEditor.HostView:OldOnGUI ()
0x000000000C646609 (Mono JIT Code) [IMGUIContainer.cs:281] UnityEngine.UIElements.IMGUIContainer:smile:oOnGUI (UnityEngine.Event,UnityEngine.Matrix4x4,UnityEngine.Rect,bool,UnityEngine.Rect)
0x000000002FB5EC3B (Mono JIT Code) [IMGUIContainer.cs:485] UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent (UnityEngine.Event,UnityEngine.Matrix4x4,UnityEngine.Rect)
0x0000000031939BFB (Mono JIT Code) [IMGUIContainer.cs:466] UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent (UnityEngine.Event)
0x0000000029AEF333 (Mono JIT Code) [IMGUIContainer.cs:447] UnityEngine.UIElements.IMGUIContainer:HandleEvent (UnityEngine.UIElements.EventBase)
0x0000000031931024 (Mono JIT Code) [MouseCaptureDispatchingStrategy.cs:98] UnityEngine.UIElements.MouseCaptureDispatchingStrategy:smile:ispatchEvent (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel)
0x0000000029AB0807 (Mono JIT Code) [EventDispatcher.cs:282] UnityEngine.UIElements.EventDispatcher:ProcessEvent (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel)
0x0000000029AAAEDB (Mono JIT Code) [EventDispatcher.cs:157] UnityEngine.UIElements.EventDispatcher:smile:ispatch (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel,UnityEngine.UIElements.DispatchMode)
0x0000000029AAAB03 (Mono JIT Code) [Panel.cs:191] UnityEngine.UIElements.BaseVisualElementPanel:SendEvent (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.DispatchMode)
0x000000002D348F23 (Mono JIT Code) [UIElementsUtility.cs:258] UnityEngine.UIElements.UIElementsUtility:smile:oDispatch (UnityEngine.UIElements.BaseVisualElementPanel)
0x000000002D34868B (Mono JIT Code) [UIElementsUtility.cs:78] UnityEngine.UIElements.UIElementsUtility:ProcessEvent (int,intptr)
0x000000002D347FE4 (Mono JIT Code) [GUIUtility.cs:179] UnityEngine.GUIUtility:ProcessEvent (int,intptr)
0x000000002D348203 (Mono JIT Code) (wrapper runtime-invoke) <Module>:runtime_invoke_bool_int_intptr (object,intptr,intptr,intptr)
0x000007FEDD8EC010 (mono-2.0-bdwgc) [mini-runtime.c:2809] mono_jit_runtime_invoke
0x000007FEDD872122 (mono-2.0-bdwgc) [object.c:2921] do_runtime_invoke
0x000007FEDD87B11F (mono-2.0-bdwgc) [object.c:2968] mono_runtime_invoke
0x000000014299C842 (Unity) scripting_method_invoke
0x00000001429964F1 (Unity) ScriptingInvocation::Invoke
0x000000014299074A (Unity) ScriptingInvocation::Invoke<bool>
0x000000013FEDF3D9 (Unity) Scripting::UnityEngine::GUIUtilityProxy::ProcessEvent
0x000000014095320C (Unity) GUIView::ProcessRetainedMode
0x00000001412D5677 (Unity) GUIView::OnInputEvent
0x000000014095311C (Unity) GUIView::ProcessInputEvent
0x00000001412D6ED5 (Unity) GUIView::ProcessEventMessages
0x00000001412CA1BB (Unity) GUIView::GUIViewWndProc
0x0000000076DD9BD1 (USER32) TranslateMessageEx
0x0000000076DD98DA (USER32) TranslateMessage
0x00000001412B5ED1 (Unity) MainMessageLoop
0x00000001412B876F (Unity) WinMain
0x0000000143F64672 (Unity) __scrt_common_main_seh
0x0000000076ED652D (kernel32) BaseThreadInitThunk
0x000000007700C521 (ntdll) RtlUserThreadStart
Basically Unity can’t compile it’s own default cs scripts and I’m not sure why. I tried switching between Mono and IL2CPP, I tried switching bewteen .NET 4.x and .NET Standard 2.0 but nothing changes.
I assume it probably has something to do with a version of C# Unity uses on my PC, but I’m not sure how exactly Unity handles compiling its scripts. How do I update the C# compiler version Unity actually uses? I assume Visual Studio is just an IDE paired with Unity for convenience and has nothing to do with actual compiling.
I also tried different versions of unity 2019 and 2018 but they all fail exactly the same.
I did first install Unity on my PC a couple years ago so maybe it tries to use some previously installed C# stuff which it used for 2017 version but which can’t compile 2019 default cs. But I’m not sure how to update that part.