I would like to create a multiplayer game using Netcode for GameObjects on WebGL.
I understand that the built in transports are not supported.
At the home page for netcode it says there are 3rd party transports that should work.
I am using Unity 2021.3 and tried to install the Netcode package version 1.0.2.
If I have the build settings targeted to WebGL I get the following error:
(0,0): error System.TypeLoadException: Could not load type 'Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle' from assembly 'UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
If I change it back to Windows, Mac, Linux the error goes away.
I am developing on a M1 MacBook Pro.
I also installed the Photon Realtime transport package from the git URL, but the error remains.
Could you try updating to version 1.1.0 of the Netcode package? I believe it contains a fix related to this issue.
How do I do this? I changed the setting to allow pre-release packages and still don’t see a 1.1.0
Within package manager, add the package by name using: com.unity.netcode.gameobjects and version 1.1.0 → click add
I just upgraded to 1.1.0 using those instructions and verified it is now using that version, but the error remains.
Here is the entire error test from the console details:
(0,0): error - System.TypeLoadException: Could not load type 'Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle' from assembly 'UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.| at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.ProcessNetworkBehaviour(TypeDefinition typeDefinition, String[] assemblyDefines)| at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.<>c__DisplayClass5_0.<Process>b__1(TypeDefinition b) in /Users/tpitman/Projects/Mindfire/Ultimate Business Quest/Ultimate Business Quest/Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Editor/CodeGen/NetworkBehaviourILPP.cs:line 75| at System.Collections.Generic.List`1.ForEach(Action`1 action)| at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.Process(ICompiledAssembly compiledAssembly) in /Users/tpitman/Projects/Mindfire/Ultimate Business Quest/Ultimate Business Quest/Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Editor/CodeGen/NetworkBehaviourILPP.cs:line 72 at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.ProcessNetworkBehaviour(TypeDefinition typeDefinition, String[] assemblyDefines)| at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.<>c__DisplayClass5_0.<Process>b__1(TypeDefinition b) in /Users/tpitman/Projects/Mindfire/Ultimate Business Quest/Ultimate Business Quest/Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Editor/CodeGen/NetworkBehaviourILPP.cs:line 75| at System.Collections.Generic.List`1.ForEach(Action`1 action)| at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.Process(ICompiledAssembly compiledAssembly) in /Users/tpitman/Projects/Mindfire/Ultimate Business Quest/Ultimate Business Quest/Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Editor/CodeGen/NetworkBehaviourILPP.cs:line 72
Not sure why the code formatter makes it all one line like that. Sorry…
Do you see the same error when following the steps I shared on the GitHub issue you opened up?
I am wondering if this occurs because of either the Collections package version or because Photon transport needs an update from Exit Games.
That will take me some more time to implement those changes. I will work on that later and get back to you as soon as I can.
I followed your directions on that twitter post including restarting the editor.
There are 17 errors remaining.
Here are some of them:
Library/PackageCache/com.unity.collections@2.1.0-exp.4/Unity.Collections/CollectionHelper.cs(229,31): error CS0117: ‘UnsafeUtility’ does not contain a definition for ‘IsNativeContainerType’
Library/PackageCache/com.unity.collections@2.1.0-exp.4/Unity.Collections/CollectionHelper.cs(230,36): error CS0117: ‘AtomicSafetyHandle’ does not contain a definition for ‘SetNestedContainer’
Library/PackageCache/com.unity.collections@2.1.0-exp.4/Unity.Collections/CollectionHelper.cs(421,31): error CS0117: ‘UnsafeUtility’ does not contain a definition for ‘IsNativeContainerType’
Did you try Photon Transport or Unity Transport?
I am wondering if those steps work for you with Unity Transport.
I get the feeling that Photon Transport might require an update from Exit Games to support these new versions.
I will start a clean project and follow your steps and see what happens.
One thing I just realized. At the top of the twitter post you did you say this:
“You’ll need the latest 22.2 beta engine version installed, make sure you check the WebGL platform when installing.”
I am not sure what you mean by that. Do you mean a beta version of Unity or something else? Please explain more what this is.
I am using Unity 2021.3.11
Yes, the errors you now observe are due to using an unsupported version of the editor. I’m assuming you are trying to use Unity Transport 2.0 for its WebGL support (hence taking on a dependency on Collections 2.1)? If so, then the minimum supported edition of the editor is 2022.2 which is currently in beta (latest is 2022.2.0b14 as of writing this).
1 Like
That makes so much more sense.
Do you know whether Photon’s webGL support would also rely on that or is it just the Unity Transport that requires that?
I would suspect that if the Photon transport was being shown as working on webgl it would have worked in LTS unity, but you can tell me better…
I’m not familiar with the Photon transport, so unfortunately can’t give you a definitive answer. But I would assume it doesn’t require a beta version of Unity. My understanding is that they have been supporting WebGL for a while now, whereas it’s quite new in Unity Transport.
That was my understanding, so I guess I am back to why am I getting the error listed above with something that supposedly has been working for a while?
That is why I opened the ticket in that github. I was expecting to get an answer from someone from the Photon team. Was that the wrong place to ask?
You have been very helpful, BTW.
You’ll need to contact Exit Games regarding their Transport, I am not sure if they have eyes on the GitHub issues repo.
1 Like