Native plugin: UnityPluginLoad not called when run in editor

  • Unity 2019.2.12f1
  • Windows 10 64-bit

I am developing a native rendering plugin. When I build a standalone Windows x64 build, UnityPluginLoad is called as expected when the DLL loads, but when I run my game in the Unity editor, UnityPluginLoad is not getting called. The DLL still gets loaded successfully. I can call other native methods it contains. The editor is just not calling UnityPluginLoad.

Here are my DLL meta settings:


Am I missing a setting?

If you are using Visual Studio to do your build, you can use a command-line tool called dumpbin.exe to look at your DLL’s exports, i.e.:


Plain vanilla C API plugins should not have any underscore prefixes nor be followed with @ and a number. There are usually four things that you need to make sure your DLL follows:

  1. Use the extern “C” in order to define C style linkage to your DLL;

  2. Ensure that you are using the __stdcall calling convention. This is basically where the called function is responsible for popping the arguments off of the stack.

  3. Export your function using __declspec(dllexport)

  4. Provide a .DEF file with your exports using the expected names without mangling.

Note, if you are including the Unity interface header file, then the UNITY_INTERFACE_API and UNITY_INTERFACE_EXPORT will supply the __stdcall and __declspec(dllexport) definition for you (they do so for cross-compiler compatibility.

Now, you do say that your DLL is getting loaded and called from a stand-alone build, but not the editor. While I’m not sure how the shader plug-ins work within Unity directly, I assume they may not load them into their processes address space and possibly use a surrogate process (this is done by some applications which load plug-ins to ensure if they crash, they don’t crash the host).

See which process your DLL is loaded by and if it is indeed a 64-bit process.

Well, it could be the same issue mentioned in that forum post. Specifically the def file which prevents name mangeling.

Thank you for your response! My native plugin does have a def file, and the exports appear to be non mangled. Here’s the output of dumpbin /exports:

They look good I think, and UnityPluginLoad is getting called in a standalone build… just not in the editor.

Thanks for the idea, but I don’t think that’s the cause in this case.