Home > other >  Why do I access the unity, written by Scott does not display the map. Click on the button. Please he
Why do I access the unity, written by Scott does not display the map. Click on the button. Please he

Time:09-19

Android studio code:
MainActivity code:
Public class MainActivity extends UnityPlayerActivity {
@ Override
Protected void onCreate (Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
}

Public void OpenTheMapOfGold12 () {

Intent Intent=new Intent (this, BasicMapActivity. Class);
Enclosing startActivity (intent);
}
}
BasicMapActivity code

Public class BasicMapActivity extends the Activity {
MapView mMapView=null;
//Button button2;
@ Override
Protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//get map control reference
MMapView=(MapView) the findViewById (R.i d.m ap);
//the activity executed when onCreate mMapView. OnCreate (savedInstanceState), create a map
MMapView. OnCreate (savedInstanceState);
@ Override
Protected void onDestroy () {
Super. OnDestroy ();
//the activity executed during onDestroy mMapView. OnDestroy (), destroy map
MMapView. OnDestroy ();
}
@ Override
Protected void onResume () {
Super. OnResume ();
.//the activity executed when onResume mMapView onResume (), to map load
MMapView. OnResume ();
}
@ Override
Protected void onPause () {
Super. OnPause ();
.//the activity executed during onPause mMapView onPause (), suspend the map drawing
MMapView. OnPause ();
}
@ Override
Protected void onSaveInstanceState (Bundle outState) {
Super. OnSaveInstanceState (outState);
.//the activity execution when performing a onSaveInstanceState mMapView onSaveInstanceState (outState), save the current state of the map
MMapView. OnSaveInstanceState (outState);
}
}



Unity 'code in
Void OnGUI ()
{
If (GUI. The Button (new the Rect (100, 100, 100, 100), "Scott map"))
{
The Debug Log (" dadawd ");
AndroidJavaClass jc=new AndroidJavaClass (com. Unity3d. Player. "UnityPlayer");
AndroidJavaObject Jo=jc. GetStatic (" currentActivity ");
Jo. Call (" OpenTheMapOfGold12 ");
}
}
}

CodePudding user response:

https://blog.csdn.net/lyh916/article/details/49123581
  • Related