I’m creating a custom editor for an item system, and for some reason, some of my scripts cannot access other scripts or namespaces. What would be causing this?

// This script can access any other script
// File located in Assets/ItemSystem/Scripts/Editor/ISEditor
namespace ItemSystem.Editor {
   public class ItemDatabaseType<D,T>  where D : ItemDatabase<T> where T: ISObject
   {
      ISObject item;  // Works fine
      
   }
}


// This script's access is very limited.  Can't access the above namespace 
// or script (even if script is in same namespace).
// File located in: Assets/ItemSystem/Scripts/ISObjects
using ItemSystem.Editor   // Doesn't work 

namespace ItemSystem {
   public class ISObject 
   {
       OtherISObject otherItem;   // Works fine
       ItemSystem.OtherISObject otherItem2; // Works fine

       // These do not work:
       ItemDatabaseType<DatabaseScript, ISObject > idt; 
       ItemSystem.Editor.ItemDatabaseType<DatabaseScript, ISObject > idt2;
          // Error: The type or namespace could not be found,
          // though DatabaseScript and ItemScript are.
   }
}

// This script has no namespace.  It can access the ItemSystem namespace, but not ItemSystem.Editor
// File located in Assets/ItemSystem/Scripts/DatabaseScripts
public class ItemDatabase<T> : ScriptableObject where T: ItemSystem.ISObject {
   ItemSystem.ISObject item;   // Works
   ItemSystem.Editor.ItemDatabaseType<DatabaseScript, ISObject> item2;   // Doesn't work
}

I figured it out. The issue is caused by placing some of my scripts in a folder called “Editor”, which allows easy access to the UnityEditor, plus they are not included in the final build. The downside is that those scripts are not detected by others outside of the folder because Unity compiles them last; so as far as other scripts are concerned, they don’t exist.

I had the same issue. My Editor scripts were not able to recognize other script’s/namespaces outside of the Editor folder. In order to fix I did the following:

  1. Move the editor scripts out of the editor folder into a folder with the rest of my scripts.
  2. Added the namespace to my editor scripts
  3. Closed monodevelop.
  4. Moved my editor scripts back into the Editor folder.
  5. Opened mono and built the project.

Now my project has namespaces for my Scriptable Objects, MonoBehaviours and Editor Scripts! Monodevelop can be fickle sometimes, but a little bit of persistence and toying can work to your advantage.