Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

`UnityEditor' could not be found??? Oo

Discussion in 'Scripting' started by IJM, Jan 18, 2011.

  1. IJM

    IJM

    Joined:
    Aug 31, 2010
    Posts:
    143
    This is the error in the console:
    The type or namespace name `UnityEditor' could not be found. Are you missing a using directive or an assembly reference?

    I'm using Unity 2.6.1 pro [C#]
     
  2. IJM

    IJM

    Joined:
    Aug 31, 2010
    Posts:
    143
    Oh, I see now.
    It isn't in the "Editor" folder.
     
    JonathanBartel likes this.
  3. TomMars

    TomMars

    Joined:
    Dec 24, 2010
    Posts:
    4
    maybe you miss some libraries which you use,add them at the begin:using libraryName;
     
  4. gioworks

    gioworks

    Joined:
    Oct 12, 2011
    Posts:
    138
    I have same problem , can you explain this ?
     
  5. flaminghairball

    flaminghairball

    Joined:
    Jun 12, 2008
    Posts:
    868
    GIOWorks: Create a folder in your Project, name it "Editor", and drag your script into the folder.
     
    orihq and Emilian0 like this.
  6. gioworks

    gioworks

    Joined:
    Oct 12, 2011
    Posts:
    138
    Yes thanks i did it. It works
     
  7. FredMastro

    FredMastro

    Joined:
    May 11, 2014
    Posts:
    6
    filibis and ruudvangaal like this.
  8. MiddleEye

    MiddleEye

    Joined:
    Feb 9, 2017
    Posts:
    16
  9. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,944
    AndyGainey likes this.
  10. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It's also not a "better" answer, because in most cases when you have "using UnityEditor", you're writing an editor script, so there's going to be lots of other editor-only stuff in it, and putting "#if/#endif" around "using UnityEditor" won't help much. Generally it's best just to put editor scripts in a folder called "Editor" (doesn't have to be in the root) and call it a day. If you have a run-time script that happens to have some editor-only functionality in it, then sure, conditional compilation makes sense in that case.

    --Eric
     
    digaxe and Ryiah like this.