In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
The process of connecting to Android SDK consists of the following four steps:
1. Call java interface (AndroidJavaClass/AndroidJavaObject) between Android Activity file and unity
After the 2.Android java code is written, it is packaged into a JAR package
3.copy Android Project to Unity
4.Android callback Unity (UnityPlayer.UnitySendMessage)
First, write the java interface between Android Activity file and unity
There are two ways to Android Activity files:
1. Inherit UnityPlayerActivityAndroid java code
The call of unity
AndroidJavaObject corresponds to the base class Object of Java. Through this class, you can construct the Java class in Android directly through the class name in Unity. Generally, we use this class to call Android code.
AndroidJavaClass inherits from AndroidJavaObject, and the relationship between it is equivalent to the relationship between Object and Class in Java. One is the instance of the class, and the other is the type of the class.
two。 Use the current ActivityAndroid java code that Unity itself is using
Xiaomi's sdk does not require us to create a separate Activity, so we directly use the current Activity that the Unity itself is using. Just note that you must use runOnUiThread to call it, otherwise it may not be called.
The call of unity
Second, after the Android java code is written, it is packaged into JAR package mode 1: let's learn how to call it in Unity. First of all, Build the current Eclipse project. All the .class files of the code are generated in the bin folder of the Android project. The path to the current project is UnityTestActivity- > bin- > classes- > com- > xys- > your .class file. Next, you need to package these .class files. On Apple's system, open the computer terminal, cd to the directory of the classes folder, and then execute the code jar-cvf class.jar * this line of code means that all .class files in the current directory are packaged into .jar files. Saving the file name class.jar is particularly important in the appeal step. = = before you generate the jar package, be sure to make sure that there is an R-beginning class file in the path you want to generate.
For example, these R files, these R-beginning files may cause your Unity to fail to send Android packages, because there are R files in Unity's own classer.jar package, which will conflict with your R files.
Third, copy Android project to unity1. Transfer res and asset copy in Android project to Assets\ Plugins\ Android
two。 Jar copy the JAR package and the corresponding SDK to Assets\ Plugins\ Android\ bin
3. Set up AndroidManifest.xml
4: Android callback unity
The first parameter is the Game Object object, so you need to bind the script to the game object.
The second parameter is the method name defined in unity.
The third parameter is the parameter that defines the method (nullable).
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.