Quick answer: CS0101 means two classes with the same name exist in the same namespace of the same assembly, almost always because a script file was duplicated (Player 1.cs) or imported twice. CS0111 means one class contains two methods with the same name and the same parameter types, such as two Update() methods. Search the project for class Player, delete or rename the copy you do not need, and merge duplicated methods into one. Unity compiles every .cs file under Assets, attached to an object or not.

The Console says a namespace “already contains a definition for” one of your classes, or that a type “already defines a member” you only remember writing once. Both errors mean the compiler found the same thing declared twice and will not choose between the copies. The fix is rarely a code change in the file the error names. It is finding the second declaration, which is often in a file you forgot exists. This guide covers what counts as a duplicate for each code, the Unity habits that create them (duplicated scripts, backup folders inside Assets, repeated asset imports, pasted code and merges), how to find the other copy, and when namespaces, assembly definitions or partial are the right tool. It also separates these from CS0104, the ambiguous reference error that looks similar and is fixed differently.

The exact error

Assets/Scripts/Player 1.cs(5,14): error CS0101: The namespace '<global namespace>' already contains a definition for 'Player'
Assets/Scripts/Player.cs(31,10): error CS0111: Type 'Player' already defines a member called 'Update' with the same parameter types

<global namespace> is how the compiler refers to code that is not inside any namespace block, which is where Unity’s script template puts every new class. If your class is in a namespace, its name appears there instead, as in The namespace 'MyGame' already contains a definition for 'Player'. The file and line identify one of the two declarations, the one the compiler read second. The other copy is not listed anywhere in the message, and finding it is the actual work. Both are compile errors: Play mode stays locked and no build is produced until they are gone.

What counts as a duplicate

For CS0101, the rule is one type per name per namespace per assembly. A class, struct, enum or interface called Player may be declared once in the global namespace of an assembly. File names play no part in this: the compiler only sees the declarations inside the files, so Player.cs, Player 1.cs and OldStuff/PlayerBackup.cs collide if each contains class Player.

For CS0111, the rule is one method per signature per class. A signature is the method’s name plus the types of its parameters, in order. These do not make two methods different: the return type, the parameter names, public versus private, or static.

void Fire() { }
void Fire(float power) { }               // fine: different parameter types (an overload)

void OnTriggerEnter(Collider other) { }
void OnTriggerEnter(Collider col) { }    // CS0111: only the parameter name differs

void Start() { }
IEnumerator Start() { yield break; }     // CS0111: only the return type differs

Several neighboring errors report other kinds of “declared twice”. The code tells you where to look:

CodeMessageWhat is duplicated
CS0101The namespace '<global namespace>' already contains a definition for 'Player'A whole class, struct, enum or interface, in two places in one assembly.
CS0111Type 'Player' already defines a member called 'Update' with the same parameter typesA method or constructor inside one class.
CS0102The type 'Player' already contains a definition for 'health'A field or property, or a field and a method sharing one name.
CS0128A local variable or function named 'hit' is already defined in this scopeA local variable declared twice in one method.
CS0260Missing partial modifier on declaration of type 'Player'; another partial declaration of this type existsA class split across files where one part lacks partial.
CS0433The type 'Player' exists in both 'A' and 'B'The same class name in two different assemblies that your code both references.
CS0104'Random' is an ambiguous reference between 'UnityEngine.Random' and 'System.Random'Nothing is duplicated. Two different types share a short name. See the section below.

When CS0101 and a wall of CS0111 arrive together

If the Console shows one CS0101 for a class and then CS0111 or CS0102 for what looks like every method and field in it, you do not have twenty problems. The compiler treats two same-named classes as one class written in two pieces, so every member that appears in both files is reported as a duplicate member as well. Remove the extra file and the whole list clears at once.

What causes it in a Unity project

  1. A duplicated script. Selecting a script in the Project window and pressing Ctrl+D (Cmd+D on macOS) creates Player 1.cs with the same class inside. Copying the file in Explorer or Finder does the same under a name such as Player - Copy.cs.
  2. A backup inside Assets. A folder such as Assets/Backup or Assets/Scripts_old is compiled like any other. So is an unzipped copy of the project dropped into Assets.
  3. The same asset imported twice. Unity matches imported files to existing ones by the IDs in their .meta files. If the first copy was added by hand without its .meta files, or they were lost in a move, importing the package again adds a second set of scripts instead of updating the first.
  4. Two assets that bundle the same helper. Two unrelated packages each ship their own copy of a small utility class, often a JSON parser or a singleton base class, under the same name.
  5. A class name you reused. You created a new GameManager script in another folder, forgetting that one exists. Unity allows two files with the same name in different folders. The compiler does not allow two classes.
  6. Two classes in one file. A tutorial’s complete script pasted below the existing class in the same file.
  7. For CS0111: pasted or merged methods. Unity’s script template already contains Start and Update. Pasting a snippet that brings its own Update gives the class two. A version control merge resolved by keeping both sides does the same.

How to find the other copy

The message names the class or the member. Search for its declaration, and expect more than one result.

# macOS, Linux, Git Bash
grep -rnw "class Player" Assets Packages --include="*.cs"

# Windows PowerShell
Get-ChildItem Assets,Packages -Recurse -Filter *.cs | Select-String "class Player\b"

For CS0111 both declarations are in the same class, usually in the same file. Search that file for the member name followed by an opening bracket, such as Update(. If you find only one, the class is declared in a second file as well, either by accident (search for the class as above) or on purpose as a partial class.

Select a search result and the bar at the bottom of the Project window shows its path. Note the paths of both copies before deleting anything, because the next step is deciding which one to keep.

Fix 1: delete or rename the duplicate file

Which copy you delete matters. Components in scenes and prefabs do not refer to a script by its class name. They refer to the ID stored in the script’s .meta file. Delete the copy your objects use and every one of them shows a missing script, even though a class with the right name still exists.

  1. Find out which file is in use. Select an object that has the component and click the Script field at the top of the component in the Inspector. Unity highlights the script asset it points to in the Project window.
  2. Compare the two files in your code editor. If the unused copy contains newer code, copy that code into the file that is in use.
  3. Delete the unused copy inside Unity’s Project window, so its .meta file is removed with it.
  4. Wait for the recompile, then open a scene and a prefab that use the script and confirm the component is intact.

If you deleted the wrong one, restore it from version control together with its .meta file. The symptoms and repair are in the referenced script on this Behaviour is missing.

If you wanted a variant, the duplicate needs a new class name and a matching file name:

// File: FastPlayer.cs (renamed from "Player 1.cs")
using UnityEngine;

public class FastPlayer : MonoBehaviour  // was: public class Player
{
}

If the copy is a backup, move it out of the Assets folder. Anything outside Assets and Packages is not compiled. If it has to stay inside the project, end the folder’s name with a tilde (Backup~) or start it with a dot. Unity ignores files and folders named that way during import. Version control is a better backup than either.

If an asset was imported twice, delete one of the two folders, keeping the one your scenes reference, and re-import the package over it if you need the newer version. When two different assets bundle the same helper class, the import dialog for a .unitypackage has a checkbox per file: untick the duplicate on the second import. Check first that the two copies are the same library at compatible versions. If they are different code that happens to share a name, use Fix 2.

Fix 2: namespaces and assemblies, when both classes must exist

Two classes may share a name when they are in different namespaces. This is the right fix when both are real, different classes, for example your Inventory and one that came with a UI kit.

// Assets/Scripts/Inventory.cs
using UnityEngine;

namespace MyGame
{
    public class Inventory : MonoBehaviour
    {
    }
}

// Any script that uses it
using MyGame;

Wrap your class, because you control that file and third-party files are overwritten on update. MonoBehaviours work inside namespaces, and the file name must still match the class name. Existing components keep their link to the script, because that link is the file’s ID. Other scripts that mention the class then need using MyGame;, or they report CS0246, covered in the type or namespace could not be found.

Putting every class of your own in one project namespace from the start prevents most collisions with imported assets, since asset code and your code no longer share the global namespace.

Assembly definitions also separate names, because the one-name rule applies per assembly. Third-party code under its own .asmdef cannot cause CS0101 against your scripts. It moves the problem instead of removing it: if your assembly references two assemblies that each define Player in the same namespace, using that name gives CS0433. If one of the copies is in your own assembly, yours wins and the compiler prints warning CS0436. Use assembly definitions to keep vendor code isolated, and namespaces to make names unique. Duplicate compiled libraries are a separate Unity error, covered in multiple precompiled assemblies with the same name.

Fix 3: merge duplicated methods (CS0111)

// Broken
public class Player : MonoBehaviour
{
    void Update()
    {
        Move();
    }

    // ... eighty lines later, pasted from a tutorial

    void Update()                        // CS0111
    {
        if (Input.GetKeyDown(KeyCode.Space)) Jump();
    }
}

// Fixed: one Update that does both jobs
public class Player : MonoBehaviour
{
    void Update()
    {
        Move();
        if (Input.GetKeyDown(KeyCode.Space)) Jump();
    }
}

Unity calls one Update, one Start and one of each collision or trigger message per script, so a second one is never what you want. Move the body of one into the other and delete the empty shell. If the two methods do unrelated things and are your own, give them different names. If they are meant to be overloads, give them different parameter types.

After a version control merge, look for the leftover conflict markers first. Lines starting with <<<<<<<, ======= or >>>>>>> are reported as CS8300, Merge conflict marker encountered. Removing only the markers keeps both sides’ versions of each method, which is exactly how a merge produces CS0111. Choose one version of each method, or combine them by hand.

A file with unbalanced braces can hide a duplicate from view or create odd errors around it. If the Console also lists syntax errors for the same file, fix those first: see CS1002 and CS1513.

What partial does, and what it does not solve

The partial keyword tells the compiler that a class is deliberately written in more than one piece, and that the pieces should be joined:

// Player.cs
public partial class Player : MonoBehaviour
{
    void Update() { Move(); }
}

// Player.Combat.cs
public partial class Player
{
    void Attack() { }
}

Every piece must carry the keyword, and all pieces must be in the same namespace and the same assembly. If one piece lacks it you get CS0260. Keep the piece that declares the MonoBehaviour base class in the file named after the class.

Adding partial to an accidental duplicate does not fix it. The keyword joins the two declarations into one class, and that class then has two of everything. CS0101 disappears and CS0111 and CS0102 take its place, one per method and field. partial is for splitting one class across files on purpose. It does not let two Update methods coexist, and it does not turn two different classes into two classes.

CS0104: the ambiguous reference that is not a duplicate

using System;
using UnityEngine;

public class Dice : MonoBehaviour
{
    void Roll()
    {
        int face = Random.Range(1, 7);
        // CS0104: 'Random' is an ambiguous reference between 'UnityEngine.Random' and 'System.Random'
    }
}

Here nothing is declared twice. UnityEngine.Random and System.Random are two different classes that live in different namespaces, and this file imports both namespaces, so the short name Random could mean either. There is nothing to delete. You say which one you mean, in one of three ways:

using Random = UnityEngine.Random;       // an alias for this file, placed with the using lines

int face = UnityEngine.Random.Range(1, 7);   // or the full name at the call

// or remove "using System;" if nothing else in the file needs it

The same happens with Object (UnityEngine.Object and object) under using System;, and with Debug when an editor’s quick fix adds using System.Diagnostics;.

Your own classes can join in. A class of yours named Random, Debug, Input, Button or Image conflicts with Unity’s in one of two ways, depending on where yours is declared. Inside a namespace that a file imports alongside Unity’s, the result is CS0104. In the global namespace, yours silently takes priority over anything brought in by a using line, in every script of the assembly. Then Debug.Log("hit") fails with CS0117, 'Debug' does not contain a definition for 'Log', in files you did not touch. The cure for both is to rename your class. Avoid giving a class the name of a Unity type.

Where Bugnet fits after a duplicate is removed

A duplicate definition never reaches Bugnet. It stops the compile on your machine, there is no build, and nothing is running that could send a report. The part with consequences for players is the cleanup. Deleting the copy that scenes and prefabs referenced leaves those objects without the component. Unity logs that as a missing-script warning, and the Bugnet Unity SDK files logged errors, exceptions and failed asserts, not warnings, so that message itself is not captured. What is captured is the next thing that happens: another script calls GetComponent<Player>() on the object, gets null and throws a NullReferenceException. The Unity SDK files that exception through Application.logMessageReceived with its stack trace, recent log lines, game version, platform and OS, and identical titles stack into one entry with an occurrence count.

That report tells you which script found nothing and in which release. It does not tell you that a deleted file is the reason, so check the prefab in the editor first when a null reference appears right after a cleanup. Setup is described in getting started.

Frequently asked questions

What does error CS0101 mean in Unity?

Two classes, structs, enums or interfaces with the same name are declared in the same namespace of the same assembly. In Unity the usual cause is a duplicated script file, a backup folder inside Assets or an asset imported twice. Find the second declaration and delete or rename it.

What does global namespace mean in the CS0101 message?

It is the compiler's name for code that is not inside any namespace block. Unity's default script template creates classes there, so every class you make without a namespace shares that one space with every other script and asset in the assembly.

How do I fix Type already defines a member called Update with the same parameter types?

That is CS0111, and it means the class has two Update methods. Search the file for the method name, move the code from one into the other and delete the spare. If you can only find one, the whole class is declared a second time in another file.

How do I find a duplicate script in Unity?

Type t:Script followed by the class name in the Project window search box to list script files with that name in every folder. To catch a class inside a differently named file, search all files in your code editor for the text class followed by the name.

What is the difference between CS0101 and CS0104?

CS0101 means one name is declared twice in the same namespace, and the fix is to remove or rename a declaration. CS0104 means two different types in different namespaces share a short name and the file imports both, as with UnityEngine.Random and System.Random. The fix there is an alias or the full name where you use it.

The error names one copy and the other is somewhere else in the project. Search for the declaration, check which file your scenes and prefabs use before deleting, and remove the spare inside Unity so its .meta file goes with it.