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. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Netcode for GameObjects Using Photon Realtime for WebGL

Discussion in 'Unity Transport' started by Hotshot10101, Nov 5, 2022.

  1. Hotshot10101

    Hotshot10101

    Joined:
    Jun 23, 2012
    Posts:
    206
    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:

    Code (CSharp):
    1. (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'.
    2.  
    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.
     
  2. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    150
    Could you try updating to version 1.1.0 of the Netcode package? I believe it contains a fix related to this issue.
     
  3. Hotshot10101

    Hotshot10101

    Joined:
    Jun 23, 2012
    Posts:
    206
    How do I do this? I changed the setting to allow pre-release packages and still don't see a 1.1.0
     
  4. CreativeChris

    CreativeChris

    Unity Technologies

    Joined:
    Jun 7, 2010
    Posts:
    448
    Within package manager, add the package by name using: com.unity.netcode.gameobjects and version 1.1.0 -> click add
     
  5. Hotshot10101

    Hotshot10101

    Joined:
    Jun 23, 2012
    Posts:
    206
    I just upgraded to 1.1.0 using those instructions and verified it is now using that version, but the error remains.
     
  6. Hotshot10101

    Hotshot10101

    Joined:
    Jun 23, 2012
    Posts:
    206
    Here is the entire error test from the console details:

    Code (CSharp):
    1. (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
    2.  
    Not sure why the code formatter makes it all one line like that. Sorry...
     
  7. CreativeChris

    CreativeChris

    Unity Technologies

    Joined:
    Jun 7, 2010
    Posts:
    448
    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.
     
  8. Hotshot10101

    Hotshot10101

    Joined:
    Jun 23, 2012
    Posts:
    206
    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.
     
  9. Hotshot10101

    Hotshot10101

    Joined:
    Jun 23, 2012
    Posts:
    206
    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'
     
  10. CreativeChris

    CreativeChris

    Unity Technologies

    Joined:
    Jun 7, 2010
    Posts:
    448
    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.
     
  11. Hotshot10101

    Hotshot10101

    Joined:
    Jun 23, 2012
    Posts:
    206
    I will start a clean project and follow your steps and see what happens.
     
  12. Hotshot10101

    Hotshot10101

    Joined:
    Jun 23, 2012
    Posts:
    206
    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
     
  13. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    150
    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).
     
    CreativeChris likes this.
  14. Hotshot10101

    Hotshot10101

    Joined:
    Jun 23, 2012
    Posts:
    206
    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....
     
  15. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    150
    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.
     
  16. Hotshot10101

    Hotshot10101

    Joined:
    Jun 23, 2012
    Posts:
    206
    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.
     
  17. CreativeChris

    CreativeChris

    Unity Technologies

    Joined:
    Jun 7, 2010
    Posts:
    448
    You'll need to contact Exit Games regarding their Transport, I am not sure if they have eyes on the GitHub issues repo.
     
    Hotshot10101 likes this.