The type or namespace name `UnityEditor' could not be found (632690)

I got this error when I want to build, I used animatorcontroller in the code for animation.

I found Ineed to put the code I used unityEditor in editor folder. but when i move all of them in the editor code. they show many class or code missing and i cant even complie the game.

Seems like you are trying to build a game that has a script(that is not needed in the game) which extends the Editor.
You have to add

#if UNITY_EDITOR
//Your code
#endif

wherever there is a piece of code that is editor-dependant.
You might want to read this:

1 Like

That means I can’t run the code.

Can you post the code?

sure

public int PlayLongAnim()
{
GetComponent().runtimeAnimatorController = anims[id];
GetComponent().Play(“Icon”+id+“_long”);
AnimatorStateInfo currInfo = GetComponent().GetCurrentAnimatorStateInfo(0);
return (int)(currInfo.length / Time.deltaTime);
}

I just beginner

That means that theat piece of code is not needed in the build, you use it for developing the game so when its going to be build the code is not needed.
Im not talking about all the code, im talkin about the code in which you use UnityEditor.
UnityEditor library needs to be in the editor, not in the actual game.

Can you provide a idea to do the same thing in the code thanks:)

Hey, please use Code Tags ( http://forum.unity3d.com/threads/using-code-tags-properly.143875/ )
The piece of code you provided does not present an issue, your error is in another place where you are using something of the Editor.
Could you provide the full script that generates the error?