Configure the Android plugin and use Unity to invoke

Source: Internet
Author: User

Method One: Release the Eclipse Android Project (tick), as IOS publishes Xcode , in eclipse in the write call

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/4D/A4/wKiom1RV8AeSOlX5AADeBLsA5iA608.jpg "title=" Picture 1.png "alt=" wkiom1rv8aesolx5aadeblsa5ia608.jpg "/>

Method Two: Use the Eclipse Publishing plug-in to call in Unity

configuration essentials in Eclipse:

Operation Process:

1. new Android Project, note the package path like mine is com.zxkj,cyy, the other steps are done directly next

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/4D/A3/wKioL1RV8HvxlE1LAABoY7HQ8F0346.jpg "title=" Picture 2.png "alt=" wkiol1rv8hvxle1laaboy7hq8f0346.jpg "/>

2. Right-click on the Android project to Import the Unity installation package . Class.jar Bag 650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M02/4D/A4/wKiom1RV8DaBVoKTAAARXCJnF3M120.jpg " title= "Picture 3.png" alt= "Wkiom1rv8dabvoktaaarxcjnf3m120.jpg"/>

path in Unity installation package:Uniy\editor\data\playbackengines\androidplayer\release\bin\class.jar

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/4D/A3/wKioL1RV8KnQ4iDaAAIqIIYrp_M880.jpg "title=" Picture 4.png "alt=" wkiol1rv8knq4idaaaiqiiyrp_m880.jpg "/>

Import Results

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/4D/A3/wKioL1RV8MCD7urnAAA0RnHDKWU450.jpg "title=" Picture 5.png "alt=" wkiol1rv8mcd7urnaaa0rnhdkwu450.jpg "/>

3. edit mainactivity650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M02/4D/A4/ Wkiom1rv8hxxoz_taaa4vfsjqpk341.jpg "title=" image 6.png "alt=" Wkiom1rv8hxxoz_taaa4vfsjqpk341.jpg "/>

Code such as:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/4D/A4/wKiom1RV8IiTKFw2AAG5RlkgWq0479.jpg "title=" Picture 7.png "alt=" wkiom1rv8iitkfw2aag5rlkgwq0479.jpg "/>

Inherit unityplayeractivity, comment red box that line of code, because you don't need to use Android 's own view, use the untiy own scene;

4. Configure the Master file androidmanifest.xml, preferably in the Unity installation Package Androidmanifest.xml Configuration, the principle is not much to say

unity

<?xml version= "1.0"  encoding= "Utf-8"? ><manifest    xmlns:android= "http ://schemas.android.com/apk/res/android "    package=" Com.unity3d.player "Android: installlocation= "preferexternal" Android:theme= "@android: Style/theme.notitlebar"     android : versioncode= "1"     android:versionname= "1.0" >    < Supports-screens        android:smallscreens= "true"          android:normalscreens= "true"          Android:largescreens= "true"         android:xlargescreens= "true"          android:anydensity= "true"/>     < applicationandroid:icon= "@drawable/app_icon"         android:label= "@ String/app_name "     &Nbsp;  android:debuggable= "true" >        <activity  android:name= "Com.unity3d.player.UnityPlayerNativeActivity"                    android:label= "@string/app_name" >             <intent-filter>                 <action android:name= " Android.intent.action.MAIN " />                 <category android:name= "Android.intent.category.LAUNCHER"  />             </intent-filter>             <meta-data android:name= "Unityplayer. Unityactivity " android:value=" true " />            <meta-data android:name= "Unityplayer. Forwardnativeeventstodalvik " android:value=" false " />         </activity>    </application></manifest>

android Span style= "font-family: ' The song Body '; > Project androidmanifest.xml , the difference statement itself against the unmodified file, think about why, as for some system access rights to continue to add

<?xml version= "1.0"  encoding= "Utf-8"? ><manifest    xmlns:android= "http ://schemas.android.com/apk/res/android "    package=" Com.unity3d.player "Android: installlocation= "preferexternal" Android:theme= "@android: Style/theme.notitlebar"     android : versioncode= "1"     android:versionname= "1.0" >    < Supports-screens        android:smallscreens= "true"          android:normalscreens= "true"          Android:largescreens= "true"         android:xlargescreens= "true"          android:anydensity= "true"/>     < applicationandroid:icon= "@drawable/app_icon"         android:label= "@ String/app_name "     &Nbsp;  android:debuggable= "true" >        <activity  android:name= "Com.unity3d.player.UnityPlayerNativeActivity"                    android:label= "@string/app_name" >             <intent-filter>                 <action android:name= " Android.intent.action.MAIN " />                 <category android:name= "Android.intent.category.LAUNCHER"  />             </intent-filter>             <meta-data android:name= "Unityplayer. Unityactivity " android:value=" true " />            <meta-data android:name= "Unityplayer. Forwardnativeeventstodalvik " android:value=" false " />         </activity>    </application></manifest>

5. Extract the plugin, copy it to the Unity project assets\plugins\android folder, or use the Publish plugin method to publish it here.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/4D/A4/wKiom1RV8PqjuoXgAAA_pE6vnMg137.jpg "title=" Picture 8.png "alt=" wkiom1rv8pqjuoxgaaa_pe6vnmg137.jpg "/>

Unzip the plug-in package, result diagram

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/4D/A3/wKioL1RV8WqAu6oEAAAqCziu1k0266.jpg "title=" Picture 9.png "alt=" wkiol1rv8wqau6oeaaaqcziu1k0266.jpg "/>

If plugin is useful to Android View also need to copy res resource file

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/4D/A4/wKiom1RV8R_yJiK7AACcMSCS31g660.jpg "title=" Picture 10.png "alt=" wkiom1rv8r_yjik7aaccmscs31g660.jpg "/>

It's over. Plugin settings

Unity Configuration and use

1. Note the package needs and the Android New Project package path Unified

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/4D/A3/wKioL1RV8ZLCJLOyAABCHfyvrfc003.jpg "title=" Picture 11.png "alt=" wkiol1rv8zlcjloyaabchfyvrfc003.jpg "/>

2. Accessing the Android method:

Androidjavaclass JC = new Androidjavaclass ("Com.unity3d.player.UnityPlayer"); Androidjavaobject Jo = JC. Getstatic<androidjavaobject> ("currentactivity"); Jo. Call (Calling the Android method name, calling the method's parameters);


Configure the Android plugin and use Unity to invoke

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.