Unity Android ¸ Java. ”µ¼¾ µ¸

download Unity Android ¸ Java. ”µ¼¾ µ¸

of 13

Embed Size (px)


В предыдущем докладе были раскрыты основные секреты и хитрости разработки на Unity Android. На этот раз от теории переходим к практике. Будут показаны примеры и различные демо озвученых ранее технологий. Вы узнаете как написать android java plugin, использовать сторонние android java libraries в Вашем Unity проекте и многое другое. Кроме доклада, в течении всей конференции, буду рад ответить на Ваши вопросы по Unity Android и помочь практически. Приходите учиться, приходите за ответами, приходите с Вашими Unity проектами. Будет интересно :)

Transcript of Unity Android ¸ Java. ”µ¼¾ µ¸

  • 1. Unity Android Java

2. . 10+ ( ) : Toolsmedia, LG Electronics, Creat Studios, Reaxion ... PC/PS2 iOS/Android/Brew/J2ME/Symbian.. 3 Unity Technologies, QA : Android/Windows Phone 8. 3. Unity Android Player. Native. ,C++/Android NDK. . , . Java: DVM/ART 4. Android JNI Helper. Java Native Interface. Java Native Interface (JNI) is a programming framework that allows Java code runningin the Java virtual machine (JVM) to call and be called by native applicationsjint JNI_OnLoad(JavaVM* vm, void* reserved) {JNIEnv* jni_env = 0;vm->AttachCurrentThread(&jni_env, 0);}jobject createJavaObject(JNIEnv* jni_env) {jclass cls_JavaClass = jni_env->FindClass("com/your/java/Class"); // find class definitionjmethodID mid_JavaClass = jni_env->GetMethodID (cls_JavaClass, "", "()V"); // find constructor methodjobject obj_JavaClass = jni_env->NewObject(cls_JavaClass, mid_JavaClass); // create object instancereturn jni_env->NewGlobalRef(obj_JavaClass); // return object with a global reference} 5. Android JNI Helper. Wrapper. Helper. ?. UnityEngine.AndroidJNI is a wrapper for the JNI calls available in C. All methods in this class are static and havea 1:1 mapping to the Java Native Interface.. UnityEngine.AndroidJNIHelper provides helper functionality used by the next level, but is exposed as publicmethods because they may be useful for some special cases.//The comments describe what you would need to do if you were using raw JNIAndroidJavaObject jo = new AndroidJavaObject("java.lang.String", "some_string");// jni.FindClass("java.lang.String");// jni.GetMethodID(classID, "", "(Ljava/lang/String;)V");// jni.NewStringUTF("some_string");// jni.NewObject(classID, methodID, javaString);int hash = jo.Call("hashCode");// jni.GetMethodID(classID, "hashCode", "()I");// jni.CallIntMethod(objectID, methodID);. Android Java Class + Android Java Object. 6. Java Exception Propagation. Android JNI Helper Java ?. JNI Call stack, 512 entries. : Java Exception Propagation 7. Android Native Plugins(ANP). Android NDK / shared libs. Assets->Plugins->Android folderextern "C" {float FooPluginFunction ();}[DllImport ("PluginName")] private static extern float FooPluginFunction ();. : Native QR Code Scanner 8. Android Java Plugins (AJP). Assets->Plugins->Android folder. single jar. multiple jars. 9. Android Library Projects(ALP). Android Project:http://developer.android.com/tools/projects/index.html#ApplicationProjects. :http://developer.android.com/tools/projects/index.html#LibraryProjects. . . : https://code.google.com/p/yuku-android-util/source/browse/AmbilWarna/ 10. Android Java Proxy. Java Interfaces accessible in Unity C#. Android Java Runnable : RunOnUiThread. : https://code.google.com/p/yuku-android-util/source/browse/AmbilWarna/ 11. Android Manifest 12. Java Plugins and UnityversionsUnity 3.5 Android Java Plugins Custom Manifest: 3 unity activities Manual conflicts resolving. . ALPUnity 4.3 Android Java Plugins Custom manifest: unity native activity only Support for old (3.5) Android Plugins custom manifest ALP. Unity 5.0 Android Java Plugins Android plugin importer. jar. . No Support for old (3.5) Android Plugins custom manifest ALP. . , ALP 13. ?