0
\$\begingroup\$

In Unity I encountered an error : "ArgumentException: An item with the same key has already been added. Key: c1b4c30c-7675-4940-8bab-31b514fbc818"

I want to find component with that GUID key and generate a new one. I used the search engine of the Unity Editor, but it does not give me anything even if I remove hyphens.

I also used a program, that searches all *.meta files in my project and extracts all GUID numbers. I couldn't find the GUID specified in the error.

This is the function that fails. (Adding to the dictionary):

        public void Register(SceneObjectGuid component)
        {
            Assert.IsFalse(string.IsNullOrEmpty(component.Id));
            //Add will trow an exception if the id is already registered
            m_Components.Add(component.Id, component);
        }

EDIT: I suppose that I can't modify that code because it reverts to the original every time Unity Editor reloads.

Does anyone know what is happening ? Why can't I find this GUID in my project despite it being the constant cause for the error ?

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

Looks like this is SceneObjectGuid from Tutorial Framework. From the description it says that it's some GUID for scene objects, this is likely why you can't find it in your meta files.

SceneObjectGuid is a MonoBehaviour which should be attached to a GameObejct,either in the scene or in a prefab. When it is attached it generates a GUID and registers it using the code you posted. When such an object is copied, stored in a prefab, imported multiple times etc, its GUID becomes duplicated, and can't register creating an error. You need to find who uses SceneObjectGuid component in your project. If you can find it using standard search, you can try some advanced tool, e.g. Unity Asset Usage Detector

If you are not using this packages it is worth looking through package manager to find who has it as a dependency and then try to reinstall that package.

\$\endgroup\$
4
  • \$\begingroup\$ I found the instance ID but it's a simple integer, so it doesn't look very promising. I also suspect that the error is caused every time I place an asset that has been copied from another project. \$\endgroup\$ Commented Jul 10 at 15:07
  • \$\begingroup\$ Try to find the SceneObjectGuid component. It can be on a GameObject in the scene or in a prefab. Most likely there are multiple object sharing the same guid. \$\endgroup\$
    – Vladimir
    Commented Jul 10 at 16:47
  • \$\begingroup\$ Did you just copy the files, or package them into a UnityPackage file to import? \$\endgroup\$
    – DMGregory
    Commented 2 days ago
  • \$\begingroup\$ I copied them at first. Then I imported them as assets. You're saying I need to package them somehow ? Could that be a reason for a crash ? I'm trying to locate a reason for a crash that is happening after quitting game. \$\endgroup\$ Commented 2 days ago

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .