UnityPlayer in an Android MapActivity

Hello UnityAnswers!

I'm building an Android app with Unity and a custom Activity. This Activity is already working well with a UnityPlayer and a CameraPreview. (The CameraPreview extends SurfaceView and implements SurfaceHolder.Callback and Camera.PreviewCallback to draw the camera view behind Unity.)

Now I want to do something similar with a MapView behind Unity. According to the Android docs, "A MapView can only be constructed (or inflated) by a MapActivity," so my plugin Activity is now a MapActivity. The trick here appears to be that the Activity's MapView must be an android.maps.MapView, so it can't also be a SurfaceView.

My question is, how can I get the effect of having Unity "punch through" the MapView as it does with the CameraPreview, while I can't make the MapView a SurfaceView as I have done with the CameraPreview? If the same technique can't be applied for a MapView, then is there some way to "scrape" the MapView and draw it onto a Plane in Unity?

Thank you in advance for any assistance!

Terrance Cohen, Ogmento, Inc.

Here's a bit of code for reference:

  public class MyActivity extends MapActivity
    implements VideoUser
  {
    private CameraPreview cameraPreview;
    private UnityPlayer unityPlayer;
    MapView mapView;
    ...

  class CameraPreview extends SurfaceView
    implements SurfaceHolder.Callback, Camera.PreviewCallback
  {
    SurfaceHolder surfaceHolder;
    Camera camera;
    VideoUser videoUser;
    ...

Hello,

I hope that you get your answer now. Sadly i have no tips to help you, however, i am really interested in the way you managed to get the android camera working behind the unity player. i'm trying to do the same thing, and the only thing i got is the camera working in the unityPlayerActivity, but the rest of my unity project is stop.

Can you please tell me how to get it work.

Thank You Greg

Hi Terrance!
I’m trying to develop an Android app displaying the camera at the background and a 3d model with unity on top of that camera but i’m new with unity and i can’t find any examples well documented. I read your post that you have successfully achieved something similar (I understand camera preview and implementing surface.callback etc…) but I don’t know how to merge it with a unity app. Can you give me a piece of advice or a bit of code. Any help would be appreciated.

Thanks!
Paula :wink:

Hi Terrance!
I’m trying to develop an Android app displaying the camera at the background and a 3d model with unity on top of that camera but i’m new with unity and i can’t find any examples well documented. I read your post that you have successfully achieved something similar (I understand camera preview and implementing surface.callback etc…) but I don’t know how to merge it with a unity app. Can you give me a piece of advice or a bit of code. Any help would be appreciated.

Thanks!
Paula :wink: