There are some rule for C# script in unity3D, such as “Inherit from MonoBehaviour”, " Don’t use namespaces."
But the external dll(C#) which is to be imported need not to follow the rules.
Is it right?
Inherit from MonoBehaviour is not a rule. If you want to write a Component that can be attached to a GameObject, then yes you MUST inherit from MonoBehaviour. Otherwise you don’t, I have tons of code that doesn’t inherit from MonoBehaviour.
This same goes for namespaces. If you want write a Component that can be attached to a GameObject, then you can’t have a namespace. For all other classes, it doesn’t matter.
I actually even have several components that are in namespaces, and are treated as abstract templates. They can’t be attached to a gameobject, but they can be inherited from by another component.
I’m going to suspect that components in external dll’s aren’t going to be able to be added to GameObjects due to the same namespace issue. The dll implicitly is it’s own namespace.
Thanks you!
The dll is componet of “c# client based on socket.io” which aim to communication with the server based on socket.io, so it need not to Inherit from MonoBehaviour and in namespaces?
Doesn’t sound like it would.
You ONLY inherit from MonoBehaviour if you’re writing a component. That’s it… no other time… if it’s not attached to a GameObject, than you don’t inherit from MonoBehaviour.
You’ll probably write a MonoBehaviour that then uses these classes you’re writing.
Thanks, I will have a try!