Inquiry Regarding Netcode - Synchronizing Network Variables Across Different Projects

I am reaching out to seek assistance with a concern I am facing while working with Netcode for gameobjects in Unity.

I am currently engaged in a project that requires separate versions for Android (URP) and PC (HDRP) due to specific technical requirements. Consequently, I have developed two parallel projects to accommodate these platform differences. Everything has been progressing smoothly until I encountered an issue with synchronizing Network Variables.

The challenge arises from the fact that the Network Variable IDs do not match between the Android (URP) and PC (HDRP) projects. As a result, synchronization issues occur, preventing the Network Variables from functioning as intended.

I would greatly appreciate any guidance or recommendations you could provide to address this situation. Whether there are best practices for handling such scenarios or specific procedures to ensure that Network Variable IDs align across different platform projects, any assistance you can offer would be invaluable.

Thank you very much for your time and support

The multi-project approach is generally tricky. I think the prefabs that you use need to be exactly the same in both projects. Meaning you cannot build them twice in two projects, you would have to create one in one project and then export it as .unitypackage and import it in the other project. That’s most likely going to be required but I cannot be sure, I’ve never used two separate projects.

The alternative would be to implement your own “variables” using just RPC calls.

I have tried, but it still loses the reference and automatically assigns another ID.

What CodeSmile suggested does work, at least for a simple test between two projects there are no issues. What is the Network Variable ID you’re referring to?

As was mentioned about GlobalObjectIdHash value generation, having multiple projects will cause differences in the values generated. Also, you could run into issues if each project has prefabs that have more or less NetworkBehaviour components than the other (i.e. the NetworkBehaviorIds will be different) or the components are ordered differently.

The core issue is how we come up with a unique identifier that, using the same project, will always generate the same GlobalObjectIdHash value. To do this, we use the GlobalObjectId that:

I will look into using custom packages where one project handles the over-all editing of the assets in the package and another just adds it via package manager. This is something that I have not had a chance to test, but will look into the different possible ways one could share network prefabs.

The biggest issue with a custom package is even though the network prefabs might have the same GlobalObjectIdHash value, any in-scene placed NetworkObjects will not.

In the end, it might be easiest to keep everything under the same project and switch between render pipelines when needed.

I am referring to the GlobalObjectIdHash. It is true that with a small test project it works correctly, but as more NetworkVariables are introduced and the scene intensifies the errors start.

Thank you very much for your contribution. I will try the last solution you have proposed.