|
I built a plugin that depends on fmodex.dll. The plugin itself works and I can use it in a standalone unity build. It doesn't work in the editor. I think that's because the editor itself has a dependency on fmodex.dll. So my plugin finds the fmodex.dll in the editors application folder. This doesn't work, because I compiled and linked against a different fmod version. So two questions:
(comments are locked)
|
|
I now have a workaround for this problem. Although it would be a much nicer and cleaner solution if Unity would rely on an official released fmodex.dll. The workaround is to delayLoad the fmodex.dll from your own dll. To do this you need to set a special linker option when building your dll. This alone won't save you, it will still throw the exception the first time you make a call to an fmod function. To prevent that you have to specify a "delayHook" (http://msdn.microsoft.com/en-us/library/f0fkfy9y.aspx). In our case we only need to handle the "dliNotePreLoadLibrary" case and reroute the call to fmodex.dll to someothername.dll. Now we can include a renamed fmodex.dll (using the specific release that you linked your dll against) in our project root folder. When we start the editor it will try to load fmodex.dll the first time we make a call to any fmod function. Instead trying to load the unity fmodex.dll it will now load the correct dll. Here's the example code for the delayHook function.
To actually use this hook you have to include this line of code on a global scope within your dll:
I hope this helps someone with a similar problem, as it took me way too long to figure this out...
(comments are locked)
|
|
I had the same problem and solved it by renaming my version of FModEx.dll to FModE2.dll and changing every occurrence of that name inside both dlls, Ex and Event, with a Hex Editor. A better description of this answer is also on this link: http://answers.unity3d.com/questions/2786/dll-loading-in-editor-on-windows/3920#3920
(comments are locked)
|
|
Just stumbled upon this problem, too. Is there a better solution than using two different FMOD builds at once? Even if the internal verison is custom built: Is the internal FMOD not fully accessible? You might be able to dllimport the functions you need from the internal dll, but you'd have to wrap the dll declaring structs and classes in you c# code, which is apita. There is a FMOD unity wrapper somewhere around (squaretangle.com if i remember correctly), but that was built to work with another fmod version. Maybe you could just remove the corresponding check from the wrapper and it will work unless there were some major changes between versions. For me this wasn't an option as I wanted to do all FMOD and audio stuff in unmanaged(C++) code for performance reasons.
Apr 19 '10 at 09:03 PM
StephanK
I just aswered your comment in the other post. http://answers.unity3d.com/questions/2786/dll-loading-in-editor-on-windows/3920#3920
Apr 19 '10 at 09:09 PM
JC
That's exactly my problem, as even if I can handle the second version I am running with two separate engines. Squaretangles solution I tried already without success but will give JCs hint a go. Maybe I should just wait for the 3.0 version, hope its coming soon...
May 02 '10 at 10:06 PM
seventyfive
(comments are locked)
|
|
Can you describe "not working" in more detail? (Unity won't start? crashes? ) Unity is using a custom build of fmod (based on 4.26), so using another vanilla (even 4.26) version of fmod could lead to a undefined behaviour. But if your not using AudioSource/Clips at all and only fmod::channels/sounds you should be fine (using 4.26). But again, I need some more details on the specific errors. What happens is that when I try to call/import methods from my dll while running in the editor it will throw a DllNotFoundException. It does find my dll, but it seems to fail to load the fmodex.dll. I suspect this is because my dll is searching for a specific version of the dll (the one it was linked against) and finds the unity specific fmodex.dll first because it is in the executables path. (unity/editor) If I run the game in standalone mode it works because there is no conflicting fmodex.dll.
Jan 28 '10 at 01:08 AM
StephanK
(comments are locked)
|
