Using scripts with the same name, different namespaces - possible bug?

Ok, so I’m having a problem where I was tasked with merging several projects into one project. All these projects have scripts with the same name that do slightly different things.

To fix the issue, I encapsulated the scripts for each project into it’s own namespace, and this works for the most part.

However, in some cases, despite dragging a script with namespace “a” onto an object, unity then runs the code from the script within namespace “b”.

In this particular case, I had an empty scene with this script in, replaced the old script with the new namespaced script, and it all worked. Now in a different empty scene, I do the same thing and I have an object that runs the old script despite having the namespaced script dragged onto it. Even if I search for references of the old script at runtime, it can’t find any, only the new namespaced script is in there, but it’s giving me errors saying the old script is running when it shouldn’t be.

Any ideas? How come this seems to randomly select a script to use at runtime instead of the specific one I dragged in?

Ah, found the issue already, another script in the old namespace was referencing the script with the new namespace, causing unity to somehow run the old namespace script… strange.

Yea, it is very unlikely that Unity mixes up namespaces. Must be user error either when creating the namespace in the first place or when assigning the references. Easy enough to get something mixed up, when it’s named the same. If you haven’t done so already, I would use a tool like Resharper or my own to put files into a namespace procedurally. If needed, maybe even write a Unity tool which does the thing automatically.