Hey community,
is it possible to use scripts in a project which have the same names? Using namespaces in c# scripts doesn’t avoid errors in Unity. Or did I a fault?
Hey community,
is it possible to use scripts in a project which have the same names? Using namespaces in c# scripts doesn’t avoid errors in Unity. Or did I a fault?
Actually, in general namespaces are supported - you only can’t use them on MonoBehaviours and a couple of others (like EditorWindow, for example). Or at least, you can’t attach those scripts to objects (or call the menu entries).
It’s really not your fault but Unity’s - given they support C#, they should really support namespaces because it’s a really basic language feature.
The good news is that you can now use namespaces for MonoBehaviours (and probably some other special Unity classes where namespaces are usually not supported) when you put them into precompiled DLLs. The bad news is that this kills most of the convenience you have when working with code files with Unity.
There’s also a request to support this on Unity Feedback: Scripting: Namespaces