How can I fix this problem about the same key when I return to the hall ?

Options

ArgumentException: An item with the same key has already been added. Key: 621965f5-6748-4c40-926f-a09b03119bff

System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at <e40e5a8f982c4b618a930d29f9bd091c>:0)

System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) (at <e40e5a8f982c4b618a930d29f9bd091c>:0)

Fusion.NetworkRunner.RegisterSceneObjects (System.Collections.Generic.IEnumerable`1[T] objects) (at Fusion/Fusion.Runtime/Runner/NetworkRunner.cs:2134)

Rethrow as InvalidOperationException: Object already registered: GameModeManager[guid:621965f5-6748-4c40-926f-a09b03119bff][hashCode:-188420]

Fusion.NetworkRunner.RegisterSceneObjects (System.Collections.Generic.IEnumerable`1[T] objects) (at Fusion/Fusion.Runtime/Runner/NetworkRunner.cs:2137)

Fusion.NetworkSceneManagerBase+<SwitchSceneWrapper>d__26.MoveNext () (at Assets/Photon/Fusion/Scripts/Prototyping/NetworkSceneManagerBase.cs:251)

UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <cbf0a658be6b4a09b610d7d2917b90f1>:0)

Best Answer

Answers

  • Hi,

    Please, provide more info about the steps you're doing.

    I believe that the problem shows up when you're changing scenes, how are you doing it? what are you trying to achieve?

    -----

    Isaac Augusto

    Photon Fusion Team

  • vimrzhang
    Options

    I use the "Runner.SetActiveScene" method to transfer from the game scene to the lobby scene, and this error is prompted. The question is, do I know which object the same key refers to? There are NetworkObject objects in both scenes.

  • Are you using any custom scene manager?

    Changing scene should not give any errors, this error says that a NO that was already been passed to the runner is trying to register again. The previous scene is unloading correctly?

    The question is, do I know which object the same key refers to?

    Not sure what you mean here, but it's the object with the NetworkGUID: 621965f5-6748-4c40-926f-a09b03119bff , according to the error log.

    -----

    Isaac Augusto

    Photon Fusion Team

  • vimrzhang
    vimrzhang
    Answer ✓
    Options

    I found this problem because I placed a networkObject in the lobby scene and set it to DontDestroyOnLoad, when I returned to the lobby scene, it was repeatedly loaded,thank you!

    I have another question for a long time. Can you help me look at it? This is the link。

    https://forum.photonengine.com/discussion/20867/about-networkcharactercontrollerprototype-question#latest