Unity3D export to Android with transparent background?

Have you solve the problem?

Hi, Does it work with iOS. Any solution to make it transparent in iOS?

@ywj7931 yes, the same checkbox (it was renamed to ā€œRender over native UIā€).

1 Like

Hi, Iā€™m sorry to call you since quite some time passed.
I want to make something like you wanted but I think my result is quite different with yours.
Can you explain me what you made with more details? (ex. screenshot(?))

For now my app is like the image I uploaded.
top of screen, it shows unity view with ā€˜main menuā€™ not my activity. (it is like a hollow)
and below that, my activity comes

Thank you

4314454--388300--ģŠ¤ķ¬ė¦°ģƒ· 2019-03-13 ģ˜¤ķ›„ 7.27.46.png

Still iam unable to get cleared color background of the unityView. Please any one could help to get the clear color backround of the unityView when integrating in the ios application.

@aleksandrk please could you help us on the transparent background of the unity while implementing in the native iOS for the 2018.0.3f2 version. It is still not changing the color while above settings is turned on. Could you help me know where is the background color implementation is written in the classes exported by the unity where we can check by changing the color of the background and get the result.

Can you post a screenshot of your camera settings and of ā€œresolution and presentation optionsā€ from the player settings?

@aleksandrk :this is the screenshot with the latest 2019 version of the unity as the option of the ā€œRender over native UIā€ is available in this unity version.

Is this the only camera that renders to the screen?

@aleksandrk : Yes, this is the only camera setting. Attaching the MethalHelper.mm file also which we get after exporting the Project in ios environment

4412095ā€“401887ā€“MetalHelper.txt (16.2 KB)

Line 69 in MetalHelper.mm sets the background color for the layer. When Unity renders a frame, itā€™s alpha-blended with the underlying view.
Iā€™m not sure, what exactly are you trying to achieve and whatā€™s not working :slight_smile:

I need the background of the unityview to be transparent so that the rendered view looks like the part of the view. Object should be visible as attached with the screenshot. In the POC, the background white color should be transparent so that the car seems like the part of the background view.

4412548--401956--IMG_FBE31222722E-1.jpeg

It should work :slight_smile:
Please make a bugreport.

Upon research, I found that the SurfaceView is rendered at the last of the window different from the view hierarchy and that it is possible to move the SurfaceView to the top by using SetZOrderOnTop(true) on SurfaceView during the time of instantiation. A sample code would be to modify the onCreate of UnityPlayerActivity -
@ protected void onCreate(Bundle savedInstanceState)
{
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);

mUnityPlayer = new UnityPlayer(this);
try{
UnityPlayer view = (UnityPlayer)mUnityPlayer.getView();
Field f = view.getClass().getDeclaredField(ā€œsā€);
f.setAccessible(true);
SurfaceView sf = (SurfaceView) f.get(view);
sf.setZOrderOnTop(true);
}catch(Exception e){
}

setContentView(mUnityPlayer);
mUnityPlayer.requestFocus();
}
The transparent pixels that were causing a hole to the desktop could be fixed by creating a dummy background view and adding it to UnityPlayerā€™s FrameLayout.
However, the downfall to this would be that other system overlays by plugins like AdMob will not be able to render above UnityGame(SurfaceView).
Also I found that custom view behind transparent area(unity game) was found consuming touch events and unity game on transparent area couldnā€™t capture touch events!

aleksandrk : https://fogbugz.unity3d.com/default.asp?1145401_n611a41p768value.

Bug report is locked for the above issue

Does this work on webgl builds?

@Umresh no, itā€™s Android and iOS only.

Hi! Iā€™m trying to create a transparent app using unity but i canā€™t. i created an empty 3D project in unity 2019.4.9f1. i set the camera clear flags to transparent black (0,0,0,0), i set the "Render over native UIā€™, i removed Vulkan, i built for android and tested on my android 10 phone. it is not transparent. can you please tell me what is wrong? Thanks in advance!

Hi!
Can you please report a bug?
Thanks!

Iā€™ve checked a lot of unity versions so I think 2019.2.9f1 is most newest and stable for this issue until it fixed in 2020 versions.

BTW Iā€™ve reported a bug.

Preset 2D
Default scene with cameraā€™s clear flags is set to Solid Color (0,0,0,0)
Start in fullscreen mode is unchecked (if you have this option in the editor, not sure that affects)
Preserve frame-buffer alpha is checked (Render over native UI)
Disable splash screen (not sure that affects)
Not worked
2020.1.6f1
2019.4.12f1 (with or without Vulkan)
2019.3.15f1 (with or without Vulkan)
2019.3.0b4
2018.4.28f1
2018.4.21f1
2018.4.17f1
2018.4.15f1
Worked
2019.2.9f1
2018.4.14f1
2018.3.14f1
2018.2.21f1