Code Error

Im using the most recent version of Unity and I uploaded a script and Im getting the error
"Error CS0103: The name “UnityEditor” does not exist in the current context. How would I fix this?

Here is the code where it takes me to.

    return UnityEditor.AssetDatabase.LoadAssetAtPath(iconPath, typeof(Texture)) as Texture;

I get same error when building standalone…
waiting…

The UnityEditor namespace is only available in the editor, not in the built products.

Scripts that reference the namespace should either be placed in the Editor folder or they should use platform defines to only compile those sections in the editor.

1 Like