Subclassed MonoBehavior in External DLLs Not Recognized

This may be a bug, or it could be I’m doing something wrong.

I am having trouble getting the editor to recognize the existence of a C# class in an external DLL under certain conditions. Specifically, when this class derives from an intermediate class that resides in a different external DLL, which in turn derives from MonoBehavior. ie:

Assembly A contains this class:
class A : MonoBehavior

Assembly B contains this class:
class B : A

The class A is recognized and shows up in the editor, but class B does not. When I move class B into the same assembly as class A, both of them ARE recognized and it all works fine.

There seems to be something about them living in separate assemblies combined with the use of inheritance that is causing the editor not to recognize class B as a valid class deriving from MonoBehavior.

Can anyone offer a solution/workaround? Is this a real bug?


Ok i’ve double checked it and it seems Unity doesn’t recognise MonoBehaviour classes in this special case. I’m not sure why since with reflection you can see the class, so it is there but Unity doesn’t include it in it’s AssetDatabase so you can’t use AddComponent.

Well you can use AddComponent but it just prints a funny debug message:

when using AddComponent<MyClass>();


when using AddComponent(typeof(MyClass));


when using AddComponent("MyClass");

        "Can't add component because class 'MyClass' doesn't exist!"

This happens because the class itself is there, but it’s not registrated in the AssetDatabase. So i would say it’s a bug (or limitation if you want)

Hello there! We managed to get Unity to patch this in 4.5.x. I verified it myself (see Monobehaviours & Editors with Inheritance across DLL boundaries don't load into Unity - Questions & Answers - Unity Discussions). Enjoy!