I could use some beginner’s help how to create a Java plugin for Unity. Basically I just want to display some text from a Java method in the Unity scene to see if the plugin works.
I’ve followed the tutorial located at http://unity3d.com/support/documentation/Manual/Plugins.html but having problems with succeeding.
So far I’ve created a JAR file which contains a class with some very simple methods such as
public class ExampleLibrary {
public String helloWorld() {
return "Hello world!";
}
}
Then I’ve added the JAR to the Assets->Plugins->Android path in Unity. The tutorial says next that I need to:
If I add the mentioned code to my MyJavaPlugin.cs file I get an error in Unity.
And here’s how MyJavaPlugin.cs looks like:
using UnityEngine;
using System.Collections;
public class MyJavaPlugin : MonoBehaviour {
public ExampleLibrary() {
}
jint JNI_OnLoad(JavaVM* vm, void* reserved) {
JNIEnv* jni_env = 0;
vm->AttachCurrentThread(&jni_env, 0);
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
Do I need to import anything into the .cs script or how can I get rid of that error message?
Thanks for help.