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