I have a C++ dll that I want to use in Unity by exporting the functions to C#. The Unity project runs on Android devices and the C++ code makes use of java. To initialize the C++ I need to call the following function first:
void api_initialize(JNIEnv* env, jobject* app_context, jobject* class_loader) {
JavaVM* vm = nullptr;
env->GetJavaVM(&vm);
if (!vm) {
return;
}
//Do other proprietary things
}
In Unity I have the following exported Dll function
[DllImport (dllName)]
private static extern void api_initialize (IntPtr java_env, IntPtr app_context, IntPtr class_loader);
My question is How do I get a JNIEnv pointer in my C# class to then pass as a parameter into this function?
I am not the creator of this API and don't have the access to modify it, so I need to get the JavaVM from the JNIEnv, not the other way around.