1

Does current 64-bit Unity still support 32-bit (x86) native DLLs?

I have a large x86 DLL with a nice C API, and an Interop file in C# that works perfectly, except in Unity. I've set all the options I can find to x86, and I've tried putting it in Plugins/x86.

Either it just doesn't find the DLL, or it finds it and complains that I need to convert it to 64-bit. But I can't do that.

Either (a) somewhere is a key factor I'm missing or (b) it can't be done and my project is dead. Which is it? A bit of sample code or a tutorial would help. I'm out of ideas.


The key to my question is that this is only about Unity, not about the general issue of x64 vs x86. The other questions are irrelevant.

And the answer is: No, you cannot use a 32-bit DLL in the Unity Editor but Yes, you can use 32-bit DLLs in a build of Unity with an x86 target. Unity allows you to provide multiple DLLs to target different platforms, but for the Editor it has to be 64-bit.

I think that's a reasonable question and a useful answer, which I have not seen stated elsewhere. I don't think it should be closed.

david.pfx
  • 10,520
  • 3
  • 30
  • 63
  • These other answers are irrelevant because they don't mention Unity. – david.pfx Mar 26 '21 at 03:01
  • Does "64-bit Unity" not imply a 64-bit DLL, and thus a 64-bit process? Either way, the duplicates make it clear that only a 32-bit process can directly use a 32-bit DLL, from which everything else follows, including that you need a 32-bit build of the Unity library to use it in the same process as another 32-bit DLL. – Peter Cordes Mar 27 '21 at 00:13
  • I guess fair enough to state the available bitnesses of the DLLs vs. editor, that's the other necessary fact that constrains one's options. Isn't it open-source, though? So one might expect that you could make a 32-bit build of the editor. – Peter Cordes Mar 27 '21 at 00:15

1 Answers1

1

A 64bit executable cannot call a 32bit dll and viceversa. So you cannot use 32-bit plugins for the unity editor because the editor is only available as a 64-bit platform.

Hamid Yusifli
  • 9,688
  • 2
  • 24
  • 48
  • This answer might be helpful, because it suggests the problem is specific to the 64-bit Unity Editor, and not to the Unity platform itself. Was this the intention? – david.pfx Mar 26 '21 at 03:03