UnityPlayer as a SubView with Transparent Background?

Hello All,

I am trying to do the following on Android (then possibly on iOS) and any advices will be appreciated:

Overlaying UnityPlayer view on top of Native Android view where only the 3D objects being drawn and no camera background (transparent background)

My current progress:

So far I managed to use my Unity project as library into another Android project and assign UnityPlayer view to a FrameLayout on top of another Android view but the camera background color showing… I tried changing the clear flag option to depth only but it didn’t work.

I also managed to use a separate GLSurfaceView which I assigned class extending UnityPlayer and implementing GLSurfaceView.Renderer to as the renderer but I am still getting opaque background.

My code as follows:

// the class extending the player
class CustomUnityPlayer extends UnityPlayer implements GLSurfaceView.Renderer {
	public CustomUnityPlayer(ContextWrapper context) {
		super(context);
	}
	public void onDrawFrame(GL10 gl) {
		super.onDrawFrame(gl);
	}
}

// inside  OnCreate function:
		m_UnityPlayer = new CustomUnityPlayer(this);
		int glesMode = m_UnityPlayer.getSettings().getInt("gles_mode", 1);
		m_UnityPlayer.init(glesMode, false);
		
		mUnityView = new GLSurfaceView(getApplication());
		mUnityView.setEGLContextClientVersion(2);
		mUnityView.setZOrderOnTop(true);
		mUnityView.setZOrderMediaOverlay(true);
		mUnityView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
		mUnityView.setRenderer(m_UnityPlayer);
		mUnityView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
				
		setContentView(R.layout.activity_fullscreen);

		FrameLayout layout = (FrameLayout) findViewById(R.id.UnityView);
		LayoutParams lp = new LayoutParams(LayoutParams.FILL_PARENT,
				LayoutParams.FILL_PARENT);
		layout.addView(mUnityView, 0, lp);

Am I missing something and is it even possible? Any help will be much appreciated.

Thanks alot

After several attempts… removing mUnityView.setZOrderMediaOverlay(true); did the trick for me.
(Tested on Unity 4.2)

Hi
i followed you’re (SolidSnake) solution and the background is transparent…
but the shadow side of the cube is also transparent… like the image show on my previews post (Apr 17 at 10:54 AM)…
i tried anther scene with more 3d objects, most of them has the same affect as the cube and some do not…
any solution for this?
(i am newbie with unity…)