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. We’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. Dismiss Notice

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

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

  1. simpan83

    simpan83

    Joined:
    Jun 17, 2022
    Posts:
    3
    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 itch.io 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

    ncontinanza

    Joined:
    May 10, 2023
    Posts:
    1
    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.