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:
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)
answered Apr 16 '12 at 11:24 PM