I am trying to export my unity project to other android projects, my Unity content will be an avatar, I am displaying my Unity content on a FrameLayout/RelativeLayout above another layout, is there anyway I can make my avatar’s background transparent? ( so that I can drag the avatar but still can see the layout on the background. a
For example: How to achieve the following? Right now,
Right now, its whatever background from Unity3D (sorry for my poor drawing):
This should be possible with Unity 2018.1.
In Android player settings, check the “Preserve frame buffer alpha” flag, and set the camera to clear color with alpha set to 0.
Keep in mind that at the moment it works with OpenGL ES only.
Open camera settings, select “Solid Color” in “Clear Flags” and make sure the color has alpha set to 0. This should do the trick if the “Preserve Framebuffer Alpha” checkbox is set.
I am just curious what files I need to replace every build, right now I replace assets/bin, libs/unity-classes.jar, jniLibs files,
1.If I have built once, and make some scene change, do I just need to replace assets/bin again?
2.If I have built once and make some project settings and build settings, should I replace all?
Has anything changed since? I am using 2018.2 with preserved alpha buffer and 0,0,0,0 rgba for the camera
if keep the “windowIsTranslucent: true” setting in Android when exported, the UnityPlayer keeps the transparency, but it is transparent through all the app views (like a hole through to the desktop)
if I remove “windowIsTranslucent: true”, then the background becomes black
The only intended use case for having “Preserve frame buffer alpha” enabled is when you want to render some content with Unity on top of some native Android UI in the same application.
That said, it works properly and there is no workaround needed. Just disable the checkmark.
So it seems that UnityPlayer on Android is using a SurfaceView which displays the content in a separate “window” and has no view hierarchy with other views in your activity. Therefore you cannot overlay with other UI elements.
There was a hack somewhere on GitHub I found that overrides some internals of UnityPlayer for it to use TextureView instead. TextureView is a normal view hierarchy member and can be animated, or overlayed with other UI views.
The problem, however, (and the reason why they chose SurfaceView) is as soon as a view in a view hierarchy updates, it propagates an update/redraw to other other views in the hierarchy (up to the root view). UnityPlayer updates many times per second, prompting other views to update many times per second, therefore resulting in a very slow fps.
There might be a way to isolate the updates of the UnityPlayer and do not propagate them to other views, but if you have an overlay view on top of or below the UnityPlayer, I don’t see how it’s possible not to redraw them.
TLDR; Unity uses SurfaceView which uses a separate “window” and is not part of your activity view hierarchy.
SIR! JUST WANTED TO LET YOU KNOW WHAT A MASSIVE LEGEND YOU ARE!
my BUTTONS AND OTHER PANEL WAS SHOWING ME MY DAMN BACKGROUND APPS AND FOR THE LIFE OF ME , I WASTED WEEKS PLAYING WITH PANELS AND IMAGES LOSING HAIR! AND THIS FIXED IT ! JUST DISABLE THIS THING AND ITS NOW FIXED! (YES I KNOW ITS CAPS!!!) THANK YOU LEGENDARY BEING!
Pardon me for bumping into this rather old thread. We are faced with a similar task. This solution did not work for us. We are using Unity3D 2018.1.3f1.
Our task is simple. We have a scene with camera attached. We want to load this scene on top of our Android app’s live camera view (which is a Fragment loaded inside a RelativeLayout). When scene actually loads, it does so with a black background and covers the entire camera view. Rest everything works in the scene itself once it’s loaded. We’d just like to get rid of the background by somehow making it transparent so that the live camera view behind it becomes visible.
Setting “Clear Flags” to “Solid Color” (with alpha 0) has the following effect. The scene loads with the set solid color background, and within fraction of a second the background turns black and stays that way. This is with “Preserve Framebuffer Alpha” checked in Unity.
When I was implementing this, I was modifying the gradle project exported by unity to show additional native Android UI underneath the Unity view. I’m not sure if any other configuration will work properly