Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Local spawn in NfGO 1.3 throws error in Prefab List

Discussion in 'Netcode for GameObjects' started by Tech-Labs, May 2, 2023.

  1. Tech-Labs


    Feb 5, 2014
    So I had (Netcode 1.2) a working setup using 12 networked prefabs defined in the Network Manager.
    Now by moving to 2021.3.24 Netcode upgraded to 1.3 and removed the Networked Prefabs list in the Network Manager by a scriptable Prefab List. The list is there and all the objects are in the created list too. No problem. Any of the objects that are in the generated Prefab List work, I want to replace one of the prefabs with a new prefab (new version). So I replace the old version in the PrefabList with the new prefab.
    Now the server can instantiate the object, but when it spawns it on the network my client reports:

    [Netcode] Failed to create object locally. [globalObjectIdHash=1222333154]. NetworkPrefab could not be found. Is the prefab registered with NetworkManager?

    Then is fails to spawn.
    The object has the NetworkObject script on it. The object is, apart from the mesh, the same as the previous object. Nothing special going on. All the other network prefab objects that were previously in my Network Manager and are now in the new prefablist, all still work. It is just the new one that does not work.

    Any ideas? Is there a special way of updating a Prefab List?


  2. Kitty-Unity


    Unity Technologies

    May 18, 2021
    Can you share any of your code around how you're updating the prefabs list? All the same APIs from 1.2 should still function, assuming you're:
    1) Updating the prefab list on both the server and the client, and
    2) Ensuring that you only do the updates after initializing
    (i.e., after calling

    I'm interested to know exactly when and how you're updating the prefabs list. It sounds like maybe there's a use case here that our tests aren't covering.
  3. Tech-Labs


    Feb 5, 2014
    Hi Kitty,
    It turned out that there was a weird mix-up in my references in the Prefab List. The list that was automatically created by Unity after the upgrade to the new version pointed to prefabs that are present, but did not contain a Network Object. Not sure how this happened as the prefabs did have that component before.
    Anyway, after updating all my prefabs manually it removed the error and the spawning works.

    I do always get this warning:

    "[Netcode] Runtime Network Prefabs was not empty at initialization time. Network Prefab registrations made before initialization will be replaced by NetworkPrefabsList."

    Not sure if that is a problem or not. My code works fine.
    Is it not okay to insert a NetworkPrefabList in the NetworkManager component before start?

    Thanks for your reply!

  4. gooby429


    Aug 13, 2019
    currently its still not fixed, even after 2 months.... (and thats just since 1.4.0)

    a workaround is to empty the network prefabs list on the net manager, and make a component sibling to the net manager that manually adds all the prefabs you want using