Unity calls Android Baidu map

Source: Internet
Author: User

Because the individual is Android small white, in this configuration was tortured for a long time, so write down this article

Tools: Eclipse + unity5.6.1

First go to the Baidu Map developer platform to download the resources you need, I just need to show the map and positioning, this time you must pay attention to, must be the function you need to select all the download, or Baidulbs_android.jar package only you choose the individual requirements of the class , after downloading the Baidulbs_android.jar class copy copies, the suffix is changed to. rar format, extracted (will be used in the assets folder inside)

Configuration in Eclipse:

First, import the downloaded package into eclipse.

Classes in the project:

Consider using unity to invoke the Android method later, so to establish a unityactivity inheritance unityplayeractivity,unity call the unityactivity in the Startmapactivity () method to start Baidulocation activity

Package Com.map.unity;import Com.unity3d.player.unityplayeractivity;import android.app.activity;import Android.content.context;import Android.content.intent;import Android.os.bundle;import Android.view.View;import Android.view.view.onclicklistener;import Android.widget.Button; Public classunityactivity extends unityplayeractivity{Context mcontext=NULL; //Button Requestlocbutton;@Override Public voidonCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Mcontext= This; }      Public voidstartmapactivity (String name) {Intent Intent=NewIntent (mcontext,baidulocation.class); //Intent.putextra ("name", name);         This. StartActivity (Intent); }}

Baidulocation is a reference to Baidu map of the example according to my own needs to do, suggest you also go to see the Baidu official case

There's another pit coming, Refer to the Baidu map example after writing Baidulocation.java I run Baidu maps do not come out, checked the next to know to configure the second class Demoapplication.java and in Androidmanifest.xml file configuration (this time I did not inherit Unityplaye Ractivity but inherited Activity, wrote a button to start Baidu map)

androidmanifest.xml Configuration I will not say, basically on the Internet, the article below I will give the project source code, including the Eclipse Project +unity project, if necessary download see it

This is the end of the Android pit.

Unity

Structure is here

The first pit is libs, and you can look closely at the difference from eclipse, where unity is armeabi-v7a,eclipse arm64-v8a

The second pit is assets, above I have said to decompress Baidulbs_android.jar, is used here, to copy in, otherwise can not show map.

Unity calls Android Baidu map

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.