-
Notifications
You must be signed in to change notification settings - Fork 437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build error when compiling using IL2CPP for Android if project uses static NetworkVariables #3101
Comments
@lllando You cannot use static NetworkVariables on any platform as each NetworkVariable needs to know what NetworkObject and NetworkBehaviour instance the property belongs to in order to properly be synchronized between clients. If you want to use NetworkVariables to store a global state, then I would recommend a separate in-scene placed NetworkObject. |
@NoelStephensUnity Ok good to know, thanks - like you said it is easy to work around. Interesting that I only ran into the error when switching away from Mono though. Could you shed some more light as to why a NetworkVariable would need to know which instance the property belongs to even in the case of static variables? My understanding is that by definition any instance could be used as the information held by the static NetworkVariable would be the same across all instances. |
@lllando A With the client-server network topology, the host/server controls the spawning, ownership, and despawning of the With the distributed authority network topology, the owner controls the spawning, and despawning of the
NetworkObjectId-->NetworkBehaviourId-->NetworkVariable Identifier--> apply delta state So, if you have a Since However, you do bring up a good point and we should have some form of notification or block during compilation that provides you with a message about this and it does appear that it will allow you to use it (which it shouldn't) under other platforms (Windows, OSX, etc.).... which it shouldn't do that. I will track this issue with our QA (@fluong6 ) and see if we can get some better documentation first and then possibly detect this use case and just not allow it. |
@NoelStephensUnity That makes sense and I appreciate the detailed breakdown of how things are handled under the hood. One thing to note is that it does currently let you use it on Android too as I had a build running on a different device (using Mono) although you would probably run into issues when attempting to publish it on Google Play. The error was only displayed when switching the scripting backend to IL2CPP to target 64 bit architectures. Either way, I think the solutions you listed at the end would be welcome additions. Thanks again for your help, Lewis |
Notes on this issue: |
Description
Build error when compiling using IL2CPP for Android if project uses static NetworkVariables. This behaviour happens when attempting to build using IL2CPP scripting backend and building to Android. Building to Android using Mono builds successfully with no errors, leading me to believe this is a bug/unintended.
Reproduce Steps
public static NetworkVariable<int>
in my case)Actual Outcome
Build fails with two error messages in console.
Expected Outcome
Build should compile successfully with no errors.
Screenshots
Error in Console:
Environment
Additional Context
Full Error Logs:
The text was updated successfully, but these errors were encountered: