🤔

CS0101#

The namespace 'Foo' already contains a definition for 'Bar'

This error is shown when there are conflicting types in the same namespace.

Typically, this is caused by accidentally duplicating a script. Often by moving a script in Unity, then saving a previously open version from your IDE. If your IDE was never aware of the move, it re-saves at the original location.

Resolution#

The error mentions a class name that has caused a naming collision. You must find and remove or rename the type causing the collision.

If you are lucky, compiler errors may point to the two locations that contain conflicting classes.

Search for a duplicate#

Search your project for the script and delete the duplicate. If your can't find it in Unity, search using your IDE's find window.

If you still cannot find the duplicate, comment out your script, once you've compiled again you should be able to navigate to the duplicate with your IDE.

Resolve collisions with namespaces#

If you recently imported an asset or script that caused this issue, you should consider moving your code into your own namespace. Namespaces are used to resolve naming conflicts. You can learn more about them here.