Just Upgraded (Unity 4.1.0f4), suddenly code needs UnityEditor namespace?

Error BCE0021: Namespace ‘UnityEditor’ not found, maybe you forgot to add an assembly reference?

I found reference to this error occuring back when 3.4.1 released. the same fixes for that aren’t resolving this.

I upgraded, made no changes to the code, tried to recompile, and this is the error I’m getting. It worked prior to the upgrade.

This shows up as the top line in 4 separate JS files. The file I’m looking at doesn’t have the word UnityEditor anywhere in it.

Is this a bug? Is this purposeful change, and I need to make an update to my (possibly obsolete) code?

Thanks for any help in the matter.

Hard to tell - could you paste some code here?

http://screencast.com/t/akoQycbe

Ok, this just got really weird. I realized that project didn’t actually use UnityEditor Anywhere. So I removed UnityEditor from the project’s references. Poof it works…

I’m a little confused as to why. I’m now a little scared to continue with Unity… However, I’ll make do. I’ll curl up next to the camp fire with a teddy bear and stab the first person who tells ghost stories.

I should also include, that everytime I close unity and restart it, in Mono, UnityEditor attaches itself to the project resources again, causing the same error. So I remove it again. So I have a functioning work around, but as that implies, I have additional work as well.

Having the same issue also, and discovered the same workaround. Interestingly, if you double click on the UnityEditor.dll in the references list to try and view in the assembly browser it comes up with the following…

“Decompilation failed:
System.IO.FileNotFoundException: Could not resolve: Mono.Posix, Version=2.0.0.0, Culture=neutral,
at Mono.Cecil.BaseAssemblyResolver.Resolve(AssemblyNameReference name, ReaderParameters parameters) in c:\BuildAgent\work\xxxxxxxxxxxxxxxx\monodevelop\main\contrib\Mono.Cecil\Mono.Cecil\Mono.Cecil\BaseAssemblyResolver.cs:line 155
at Mono.Cecil.DefaultAssemblyResolver.Resolve(AssemblyNameReference name) in c:\BuildAgent\work\xxxxxxxxx\monodevelop\main\contrib\Mono.Cecil\Mono.Cecil\Mono.Cecil\DefaultAssemblyResolver.cs:line 57
at MonoDevelop.Projects.Dom.DomCecilCompilationUnit.SimpleAssemblyResolver.Resolve(AssemblyNameReference name) in c:\BuildAgent\work\xxxxxxxxxxx\monodevelop\main\src\core\MonoDevelop.Core\MonoDevelop.Projects.Dom\DomCecilCompilationUnit.cs:line 178
at ICSharpCode.Decompiler.Ast.Transforms.IntroduceUsingDeclarations.Run(AstNode compilationUnit) in c:\BuildAgent\work\xxxxxxxxxxxxxxxxx\monodevelop\main\contrib\ICSharpCode.Decompiler\Ast\Transforms\IntroduceUsingDeclarations.cs:line 66
at ICSharpCode.Decompiler.Ast.Transforms.TransformationPipeline.RunTransformationsUntil(AstNode node, Predicate1 abortCondition, DecompilerContext context) in c:\BuildAgent\work\xxxxxxxxxx\monodevelop\main\contrib\ICSharpCode.Decompiler\Ast\Transforms\TransformationPipeline.cs:line 60 at ICSharpCode.Decompiler.Ast.AstBuilder.RunTransformations(Predicate1 transformAbortCondition) in c:\BuildAgent\work\xxxxxxxxxxxxx\monodevelop\main\contrib\ICSharpCode.Decompiler\Ast\AstBuilder.cs:line 116
at MonoDevelop.AssemblyBrowser.DomMethodNodeBuilder.Decompile(TextEditorData data, ModuleDefinition module, TypeDefinition currentType, Action`1 setData) in c:\BuildAgent\work\xxxxxxxxxxxxxx\monodevelop\main\src\addins\MonoDevelop.AssemblyBrowser\MonoDevelop.AssemblyBrowser\DomMethodNodeBuilder.cs:line 158”

I should also point out that if you just save code in mono and let unity build it, it compiles fine. But if you try and compile in mono it dies as above.

Same problem here - reading the threads for the similar V3.4.1 issue, it sounds like it was a bug in that release, is the same true this time, are more people seeing this?

Also happens in 4.1.2f1:

Error BCE0021: Namespace ‘UnityEditor’ not found, maybe you forgot to add an assembly reference? (BCE0021) (Assembly-UnityScript-firstpass)

If you can go back, do it and use 4.0.0f7.

Hi together!

I also had these problems (see above) and found the solution with this post http://answers.unity3d.com/questions/419565/unity-41-javascript-compile-unityeditor-not-found.html?sort=oldest.

I provide a small binary (Windows) which watches and fixes related project files.

https://bitbucket.org/mviranyi/unity-patches/downloads/UnityBCE0021_20130623.zip

Hope it helps :slight_smile: