What is the best way to handle NetworkObjects in different Unity Projects

I am in the middle of porting over an existing project to use Netcode. I have one project that is setup for iPad, the other with VR.

Issue I am having is with using NetworkObjects and miss matched GlobalObjectIdHash. I have tried:

  • Unchecking Force Same Prefabs in Network Manger.
  • Overriding the Hash in the NetworkPrefabList scriptable object (this seems to do nothing?)

What are some other options I can look at to solve this problem (without combining both into one project which would be a nightmare).

Thanks.

I‘m thinking, perhaps the global Id persists between the project if you use the exact same asset. Try creating a network prefab in one project and make it work with NetworkManager. Then export this prefab as .unitypackage and import it in another project to see if it still complains about GlobalHashId mismatch.

Btw pretty sure this global id hash has nothing to do with the object‘s GetHashCode() method if that‘s what you implemented.

I was curious about this so I had a look at the source code. You can override what network object to spawn on a client with something like this:

public class SceneController : MonoBehaviour
{
    [SerializeField] Card card;

    private void Start()
    {
        Application.targetFrameRate = 15;
 
        NetworkManager.Singleton.OnClientStarted += OnClientStarted;
        NetworkManager.Singleton.StartClient();
    }

    private void OnClientStarted()
    {
        NetworkPrefab networkPrefab = new NetworkPrefab();
        networkPrefab.Override = NetworkPrefabOverride.Hash;
        networkPrefab.OverridingTargetPrefab = card.gameObject;

        NetworkManager.Singleton.NetworkConfig.Prefabs.NetworkPrefabOverrideLinks.Add(2893958005, networkPrefab);
    }
}

It doesn’t look like the server provides the GlobalObjectIdHash’s so they’ll have to be hard-coded in some way like the above. In quick testing network variables and rpc’s on the object appeared to behave normally. I tested this without a network prefab list as it seems to be redundant with this method.