- Home /
Question by
$$anonymous$$ · Dec 15, 2015 at 05:27 PM ·
androidrenderingandroidpluginjarjni
[Android] Call .jar function on render thread using JNI
Hi,
I have a unity AR app that I want to use some custom GLES rendering on. I've got everything working with regards to generating .jar files and calling the methods on those .jar files (using JNI)
But I need a way to call methods on the render thread. So far, I've see many examples that show how to write native android plugins in Java and call methods from Unity C# using JNI, but all of them use activityContext.Call("runOnUiThread", new AndroidJavaRunnable(()... . like so.
void RunOnRenderThread()
{
using(AndroidJavaClass pluginClass = new AndroidJavaClass("com.company.testplugin")) {
if(pluginClass != null) {
exampleObject = pluginClass.CallStatic<AndroidJavaObject>("instance");
activityContext.Call("runOnUiThread", new AndroidJavaRunnable(() => {
exampleObject.Call("initTextureId", textureID);
}));
}
}
}
Is there a runOnRenderThread instead of runOnUiThread.
If not how can I get render thread from unity context? (AndroidJavaClass("com.unity3d.player.UnityPlayer"))
Comment