- Home /
32bit and 64 bit plugin environment
Hey
I'm working on a Unity plugin. Since the editor is 32bit I need the plugin to be 32 bit. However for the final application we are making the assets are so big that we need to build the project and plugin for 64bit. How do developers usually create an environment where 32 and 64bit dll's can coexist in Unity?
What we've found so far is the you can import both dll's and use IntPtr.Size to distinguish between the architectures and invoke the correct dll, but that's not exactly pretty nor efficient. What we would like is something along the lines of
#if UNITY_STANDALONE_WIN64
[DllImport ("Plugin64")] ...
#else
[DllImport ("Plugin32")] ...
#endif
so we can choose which to use at compile time. Does Unity or C# support something like this? We've tried _WIN64 and WIN64, but those aren't defined.
Another solution we've found that works but isn't pretty is to simply swap the dll's after the project's been build, but this irks us just as much and isn't exactly a great solution since it requires manual work from the developer each build. (Yes we cold setup a build script and we have, but we would still have to remember to do it for each new project and we all know how forgetful developers are... :))
Hoping someone has a better solution.
/asger
You should definitely post the lack of a 32/64 bit directive as a bug/missing feature. Hopefully it would be simple for Unity to add.
I'm hoping the reason they haven't added a Unity specific one is because C# natively provides it. But yes if C# doesn't either then Unity definitely should
The only things I've been able to find are runtime. Good luck in your search.
I heard this was co$$anonymous$$g in Unity 4 - anyone know what the #define is?
Answer by AndreasSommer · Dec 10, 2014 at 03:18 PM
Unity 5 brings new defines, see here.
Unity 5 will have UNITY_64 and UNITY_32 defines for standalones, as well as UNITY_EDITOR_64 and _32.