x


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;
    ...
more ▼

asked Dec 28 '10 at 06:41 PM

Terrance gravatar image

Terrance
1 1 1 1

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

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 ;-)

more ▼

answered Oct 14 '11 at 08:34 AM

PaulaCL gravatar image

PaulaCL
18 1 1 2

(comments are locked)
10|3000 characters needed characters left

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 ;-)

more ▼

answered Oct 14 '11 at 08:34 AM

PaulaCL gravatar image

PaulaCL
18 1 1 2

(comments are locked)
10|3000 characters needed characters left

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

more ▼

answered Feb 28 '11 at 04:28 PM

Greg 10 gravatar image

Greg 10
1

hi friends once you search QcarCom it is free plugin for ios/android also . if you need you will get on asset store in free . it will help to your camera directly.

Oct 21 '11 at 08:17 AM lbalasubbaiahapps
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3132
x2615
x409
x207
x20

asked: Dec 28 '10 at 06:41 PM

Seen: 2340 times

Last Updated: Oct 21 '11 at 08:18 AM