Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question My WebGL build stopped working after I broke out some code into libraries

Discussion in 'Web' started by simpan83, Jun 1, 2023.

  1. simpan83


    Jun 17, 2022
    I used to have all my C# code in the Unity directory itself, but I decided to break out the logic parts into a standalone library (since it is also going to be run on a server eventually). I also added some external libraries (Newtonsoft.json and Randomizer.NET). I've configured the library to build with C# 9.0 and .NET framework 471, and this doesn't give me any errors in Unity when I transfer the built DLL files there.

    When I play my game in Unity, it works fine. But when I make a WebGL build, deploy it to and run it there, the game breaks immediately, and in the chrome console, I see this:

    PlatformNotSupportedException: Operation is not supported on this platform.
    at System.Reflection.Emit.DynamicMethod..ctor (System.String name, System.Type returnType, System.Type[] parameterTypes, System.Type owner, System.Boolean skipVisibility) [0x00000] in <00000000000000000000000000000000>:0

    I am fairly new to C# development and don't fully understand what versions of .NET and C# work with Unity etc. But I'm running the latest version of Unity.

    Anyone able to help me? Thanks in advance!
  2. ncontinanza


    May 10, 2023
    I had this very same problem, related to the deserialization of JSON with Newtonsoft.json.
    I solved it by removing the Newtonsoft.json package and replacing it with the JsonUtility that's implemented in the UnityEngine.JSONSerializeModule module.