- Home /
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; ...
Answer by Greg 10 · Feb 28, 2011 at 04:28 PM
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 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.
Answer by PaulaCL · Oct 14, 2011 at 08:34 AM
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 ;-)
Answer by PaulaCL · Oct 14, 2011 at 08:34 AM
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 ;-)
Your answer
Follow this Question
Related Questions
show Alertdialog in android 0 Answers
How can I replace correctly the main activity on the Android Manifest? 0 Answers
Android plugin & Activity help needed - "GetMethodID method not found" problems 0 Answers
android: why scene goes black when showing new activity? 3 Answers
Android - Touch input won't work, Invisible activity in front of Unity activity 0 Answers