I make some model in scene,and set 【MainCamera’s ClearFlags】 is “SolidColor”,【Background】is black(rgba:0,0,0,0 alpha is 0),not use skyBox. 【ProjectSettings → Player → Android → Resolution and Presentation → RenderOverNativeUI* 】is “true”.
I export project on Android project,and modify thr Android code as follows: ↓MainActivity.java ↓
@Override protected void onCreate(Bundle savedInstanceState)
{
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
String cmdLine = updateUnityCommandLineArguments(getIntent().getStringExtra("unity"));
getIntent().putExtra("unity", cmdLine);
mUnityPlayer = new UnityPlayer(this);
FrameLayout frameLayout=(FrameLayout)findViewById(R.id.content);
frameLayout.addView(mUnityPlayer.getView());
try {
Field f=null;
f=mUnityPlayer.getClass().getDeclaredField("s");
f.setAccessible(true);
SurfaceView sf= null;
try {
sf = (SurfaceView)f.get(mUnityPlayer);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
sf.setZOrderOnTop(true);
sf.getHolder().setFormat(PixelFormat.TRANSPARENT); //全透明
mUnityPlayer.requestFocus();
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
//新增界面透明设置,不知道是否可用
//View v = findViewById(R.id.content);//找到你要设透明背景的layout 的id
//v.getBackground().setAlpha(20);//0-255是透明度范围
}
Core code: sf.getHolder().setFormat(PixelFormat.TRANSPARENT); //全透明.
I just want the unity scene background to be transparent,not model transparent.But i find model and background is all transparent.
Can someone help me achieve this effect? God bless the zealous!
the terrain above is wrong.

