I have a dll file that I am using inside Unity and it works when I reference it in Windows build. However when I try make a WebGL build, the build fails because of the dll. How do I make the dll support WebGL as well?
You can only use managed DLLs for WebGL, and only such DLLs which use .NET features supported by Unity.
Meaning you cannot just use any DLL file for WebGL, even if it works for other (non AOT) platforms such as Windows.
See here for more info: I can't get an external dll to work when building for webGL - Questions & Answers - Unity Discussions
But is there a way that I can edit my dll file to support webgl platform?
When you say „my DLL“ and by that you mean that you created that DLL file, then possibly. As long as the above is true. If you got that DLL from some place and it isn‘t working and there is no explicit mention of „supports Unity WebGL“ then no, absolutely no, it will not work.
yeah you are right. I have created this dll. It already is supported on Windows platform. Just have no clue on how to make this possible on WebGL as well.
Throw the code of that DLL into the project itself and remove the DLL. Then check if the build works. If it doesn’t, you may get a better error message I hope.
But if you use namespaces, classes or other DLLs (ie Windows API native calls like FileBrowser) in the DLL that aren’t available in Unity scripting and that was the reason to make that DLL, then it’s just not going to work. WebGL (browser in general) is a restricted platform, more so than any other including iOS and UWP.
Well, you never said if the DLL was native or not.
To whoever finds this thread, and wonders about using a native DLL in a WebGL build – yes, that is possible if you have the source code of it. See the following links:
Of course this is not a simple topic and there might be some restrictions, but I guess that whatever works with Emscripten is just going to work.
If your DLL is managed then it might be possible too, if Unity manages to do its IL2CPP thing on it.
However, native DLLs required by managed (.NET) DLLs might not actually work, I’m not sure if Unity is going to properly recognize the dependency and pack everything correctly. Most probably some trick like re-linking all the native DLL functions from your code, to maintain the signatures for the linker, or including the managed DLL instead in its source form, with explicit references for the functions from the native one, might work.