I’m starting to be a bit anxious about my issue, for the first time today I tried to build a scene of a game I’m working on, and I got the following log :
Error building Player because scripts had compiler errors
Build completed with a result of ‘Failed’ in 25 seconds (24599 ms)
UnityEditor.EditorApplication:Internal_CallGlobalEventHandler()
UnityEditor.BuildPlayerWindow+BuildMethodException: 2 errors
at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002bb] in :0
at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in :0
UnityEditor.EditorApplication:Internal_CallGlobalEventHandler()
I spent a lot of time checking my scripts, it seems to be working when I completely delete my scripts folder, but if I try to get them one by one to find the faulty one, it just doesn’t work until they are all gone… I really don’t know what to do.
Check your using statements to look for things like using UnityEditor; existing in a script outside of an Editor folder.
Also check for other irrelevant includes. If you’re using the Rider IDE, it is notoriously irritating about puking extra using statements all over your code (just because you mistyped a method usually) and is responsible for breaking our team’s build at least once a month.
Yes, that’s what I found online but I must have done that about 5 times and I’m pretty sure I don’t use “UnityEditor” in any of my scripts… As for the rider IDE I didn’t even know what it was.
What target are you buildilng for? (PC, Mac, Android, WebGL, etc.)
Can it build for a different target? (if you are able to target two things)
Are you sure there are no other errors or warnings with more salient information in it? The above error looks sorta like “we had a lot of problems, this is the final give up…”
Okay I finally did fix it, it was some other “using” statement that had been added on some scripts (I genuinely don’t know how) called something semothing.lifetime, erasing it fixed it. Thanks for the help !
The usual way is that you are using an editor with a setting enabled that tries to be helpful. Rider does this, I’m sure others do as well.
I highly recommend using source control so that you can actually SEE all changes made to a script before you commit it. The using statements are at the top so you can instantly spot, “Hey, I didn’t type that using!” and revert that line before committing.