I use an library .jar in my project.
How add .jar in project Unity and use with C# language?
Thank you
I use an library .jar in my project.
How add .jar in project Unity and use with C# language?
Thank you
UNITY
ECLIPSE
Eclipse will build a .Jar file. You need to copy that file into Unity. The file is found in your workspace. The easiest way to get the path is to select the file in Eclipse and open the Properties window. You can look at what’s inside the .jar file if you add the .zip extension to it and open it with any application which can view zip files.
UNITY
In the Project view, create a “Plugins” folder. Then create an “Android” folder inside the plugins folder.
Create a new C# file in Unity, and name it “CallJavaFromUnity .cs”. Then just start calling
EXAMPLE
//The comments describe what you would need to do if you were using raw JNI
AndroidJavaObject jo = new AndroidJavaObject("java.lang.String", "some_string");
// jni.FindClass("java.lang.String");
// jni.GetMethodID(classID, "<init>", "(Ljava/lang/String;)V");
// jni.NewStringUTF("some_string");
// jni.NewObject(classID, methodID, javaString);
int hash = jo.Call<int>("hashCode");
// jni.GetMethodID(classID, "hashCode", "()I");
// jni.CallIntMethod(objectID, methodID);
or
AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
// jni.FindClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity");
// jni.GetStaticFieldID(classID, "Ljava/lang/Object;");
// jni.GetStaticObjectField(classID, fieldID);
// jni.FindClass("java.lang.Object");
Debug.Log(jo.Call<AndroidJavaObject>("getCacheDir").Call<string>("getCanonicalPath"));
// jni.GetMethodID(classID, "getCacheDir", "()Ljava/io/File;"); // or any baseclass thereof!
// jni.CallObjectMethod(objectID, methodID);
// jni.FindClass("java.io.File");
// jni.GetMethodID(classID, "getCanonicalPath", "()Ljava/lang/String;");
// jni.CallObjectMethod(objectID, methodID);
// jni.GetStringUTFChars(javaString);
All these examples are from the documentation