- Home /
The question is answered, right answer was accepted
"UnityEditor" namespace not found...
This happens only when I try to build the project, when I run Unity no error shows. (Actually it crashes)
Any idea? Thanks.
Answer by gilley033 · Apr 19, 2013 at 03:16 AM
Hello, have you tried using platform dependent compilation?
I was having a similar problem with one of my scriptable objects. My scriptable object was not an editor script, but it had OnInspectorGUI code in it (used so I only had to write the inspector gui for the scriptable object once).
I fixed the issue by putting #if UNITY_EDITOR before the using UnityEditor directive and #endif after it. You will also need to surround your GUI code with these same tags.
Hope this helps!
I like your walkaround, if it works, than thanks for sharing.
it works perfectly, actually the "correct" answer is just stupid and does not solve all issues you might have, for example handles ... you just need them on the object
I did not understand, can someone explain it for me please? Yes since I put these commands it builds without errors but while apk running the part which I put command does not run. I just want to collect materials from a folder. Is there a way to make it? The thing that I cant understand is why do they put if it wont be usefull. How can I collect all materials in runtime, anyone knows how to do it?
I just want to clarify for people co$$anonymous$$g along trying to understand this. This question has two answers.
1. Unity intends for you--as part of your workflow--to put all scripts that modify the editor or include the UnityEditor namespace to be in a folder (or sub folder) in your project named "Editor". Folders with this name are special. On compile, Unity checks for this detail and it will overlook these scripts on compilation and not compile them into the finished build. 2. However, Gilley033's answer here is quite clever. Apparently if you want to avoid moving your scripts (for whatever reason) you can in some cases uses the platform dependent compilation code described here. I never thought about doing that. Very interesting and thanks.
Answer by softrare · Sep 12, 2012 at 10:36 AM
You have to place this script in a directory called "Editor" in the root of your project hierarchy.
I got same error and it solved by placed the script to Editor directory. thank u
This worked for me, it is a good solution to separate game/editor files
By the way. The "Editor" folder doesn't even have to be in the root (anymore?). It can be a subfolder.
Solved by putting every scripts that uses UnityEditor into folders called Editor. and yeah those folders don't have to be in the root folder. It seems that Unity will ignore every scripts inside Editor folder when building.( got a build error after moving one of my essential scripts into them
Answer by Kryptos · Sep 12, 2012 at 11:33 AM
Built game cannot use the UnityEditor namespace. This namespace comes with the UnityEditor.dll assembly that is not shipped (and not compatible) with any build made by Unity.
Scripts that use this namespace are only meant to be executed inside Unity Editor.
Ok... so where should I put this script? Or what should I do to avoid build errors?
Right now I removed it, the better solution?
Don't use any editor capabilities inside a script that is meant to be shipped.
Try first by removing using UnityEditor;
. Then cut/paste the code using this namespace into another script.
So glad I found this thread. I thought I was clever by using UnityEditor.AnimationUtility to get animation data from characters into an array without assigning them in the inspector. So much for that idea. Thanks @$$anonymous$$ryptos!
Put in a folder in the main assets directory called Editor
Seth got it. Works perfectly. Also kudos to $$anonymous$$ryptos for getting the first part.
Answer by Niklasi17102000 · Jun 29, 2014 at 04:10 PM
The problem is: The namespace "UnityEditor" can only be used if you are in the Unity Editor program. I have the same Problem, too. But I need the "using UnityEditor" for one of my scripts to load files from assets.
Guys, Then how do I implement a radio button (using v4.6
and OnGUI
code) if I cannot have UnityEditor
in my standalone? I cannot move my script, nor can I simply use #if UNITY_EDITOR
tags to disable that part of code, because I want it to run in the standalone... If I put the CrossPlatformInputInitialize.cs
script in my Strea$$anonymous$$gAssets
meant to be built and shipped, how can I reference it?
@HamFar: I don't think that the radio buttons in the UnityEditor namespace were really meant for production use - only for building and testing. You'll want to go through the new GUI system documentation. I unfortunately don't have time to look, but you can start at http://docs.unity3d.com/$$anonymous$$anual/UIOverview.html which will give you a good, solid start with using the new GUI system the way it was meant to be used. Hopefully that will make life easier for you.
@VCC_Geek: Thank you. I have to maintain a big software app that was developed with Unity 4.6
and OnGUI
code, so upgrading to Unity 5
and using the new UI
system is not an option for me. But I thought if I can figure how to reference the CrossPlatformInputInitialize.cs
script that enables Editor
capabilities, that will be a good hack for this dilemma! So, here is what I have written so far, and I just need to figure out what code to put ins$$anonymous$$d of the commented line:
#if UNITY_EDITOR
GUILayout.BeginHorizontal( displayStyle1 );
GUILayout.Label( field.tagLine, GUILayout.Width( Screen.width/3 ) );
selGridInt = GUILayout.SelectionGrid( selGridInt, selStrings, 3, EditorStyles.radioButton );
GUILayout.EndHorizontal();
inputs[i] = selStrings[ selGridInt ];
#elif UNITY_STANDALONE
string standalonePath = Application.strea$$anonymous$$gAssetsPath;
string editorPath = standalonePath + Path.DirectorySeparatorChar + "Editor";
// What goes here ??? = GetComponent<CrossPlatformInputInitialize>();
GUILayout.BeginHorizontal( displayStyle1 );
GUILayout.Label( field.tagLine, GUILayout.Width( Screen.width/3 ) );
selGridInt = GUILayout.SelectionGrid( selGridInt, selStrings, 3, EditorStyles.radioButton );
GUILayout.EndHorizontal();
inputs[i] = selStrings[ selGridInt ];
@HamFar: You shouldn't need Unity 5 to have the new GUI system. I believe it was introduced in 4.6. The old system is still present in 4.6 (and 5?) for backward compatibility. That said, you might want to set up a sandbox environment with a complete copy of your codebase and Unity 5 just to see how much work it would be. $$anonymous$$y own experience has been that my projects update pretty seamlessly to newer versions. If you just tiptoe through it in the sandbox, you should be able to back out easy enough if it turns out to be too much.
Answer by IPT · Oct 16, 2013 at 09:48 AM
Had the same problem, cause I have changed the location of the Orthello to be under plugins folder, when I moved it back to be under the 'Assets' folder, it fix it.