Unity integration having "Color" in default namespace
Posted: 26 Mar 2013, 12:46
When trying to play with NoesisGUI and adding it to an existing project I noticed lots of compiler errors in non NoesisGUI related code. Searching a little revealed what the problem is:
Scripts / Noesis / Proxies has a whole lot of classes residing in the default namespace. One of them is "Color" - and since UnityEngine also defines Color (among others, of course), this is causing trouble. Because the root namespace is always available to every single class in the project - even when I don't say "using default"
Maybe you need to do this for some reason - but in general, it's really bad design to put stuff into the default namespace. The kind of "bad design" that actually breaks peoples projects by just adding your package. And the worst part of it: People may not even know it's you who broke their project because they'll see the compilation errors in somebody else's package (actually, one of the most annoying support cases I've ever had with ScoreFlash was for exactly that reason: some other author just put their stuff in the default namespace and then ScoreFlash threw compilation errors that were very misleading and confusing).
For MonoBehaviours and editor classes, unfortunately, Unity didn't support using namespaces in versions prior to 4.0; so if you inherit from MonoBehaviour (or some editor classes), *and* you want to support Unity "pre-4.0" (like 3.5.7), there's not much you can do.
For "Proxies", however, I'd really appreciate to have all those classes in their appropriate namespace Noesis.Proxies. That way, when I need any of them, I can say "using Noesis.Proxies" ... and in all other cases, it doesn't break my existing code
Scripts / Noesis / Proxies has a whole lot of classes residing in the default namespace. One of them is "Color" - and since UnityEngine also defines Color (among others, of course), this is causing trouble. Because the root namespace is always available to every single class in the project - even when I don't say "using default"
Maybe you need to do this for some reason - but in general, it's really bad design to put stuff into the default namespace. The kind of "bad design" that actually breaks peoples projects by just adding your package. And the worst part of it: People may not even know it's you who broke their project because they'll see the compilation errors in somebody else's package (actually, one of the most annoying support cases I've ever had with ScoreFlash was for exactly that reason: some other author just put their stuff in the default namespace and then ScoreFlash threw compilation errors that were very misleading and confusing).
For MonoBehaviours and editor classes, unfortunately, Unity didn't support using namespaces in versions prior to 4.0; so if you inherit from MonoBehaviour (or some editor classes), *and* you want to support Unity "pre-4.0" (like 3.5.7), there's not much you can do.
For "Proxies", however, I'd really appreciate to have all those classes in their appropriate namespace Noesis.Proxies. That way, when I need any of them, I can say "using Noesis.Proxies" ... and in all other cases, it doesn't break my existing code