Unity export with transparent background

hi all,
have search everywhere for a straight answer to this. I’m trying to export a Unity scene and have it overlay on top of iOS. Is there anyway to do this? Does Unity offers any solution for this kind of integration with native mobile app?
I’ve seen a demo of it on

…but the last comment says that it doesn’t work in Unity5.x -

forget to add that I have experiment with Camera's Clear Flags Settings: - set to "Depth Only"/ "Solid Color" (alpha 0)/ - nope doesn't work have also set the Camera's Culling Mask Settings: - to only the 3D object's layer - nope doesnt' work as well Unity always appears on top of iOS with a black background...

–

I didnt code it so you can copy and past it, but if you have any sort of programming knowledge you should be able to see what to do, but give me a min and I will post the complete code for you

–

@dandelo99 Did you get it working?

–

3 Answers

3

Thanks to someone who comment in the last post at: GeekyHamster.com: UnityPlayer as Subview with Transparent Background (iOS)

I tried it and it works nicely…

  1. In Unity, MainCamera ClearFlags set to solid color with alpha = 0
  2. Export to iOS
  3. In Xcode classes folder, search for 2 files :

a - GlesHelper.mm in CreateSystemRenderingSurfaceGLES method - Add this line:-

surface->layer.opaque = NO;

b - MetalHelper.mm in CreateSystemRenderingSurfaceMTL method -
Add these lines:-

surface->layer.opaque = NO;
CGFloat backgroundColor[] = {0,0,0,0};

ta-dah~~ transparent background. Tested on Unity version 5.2.3f

So great. Thank you for that. Do you know if it's possible to do the same thing with a standalone app?

–

Hi, been looking for this for quite sometime now, do you know how to do this with Android? Thanks a ton.

–

Assets/SetFireC.cs(2,20): error CS0116: A namespace can only contain types and namespace declarations i take this error is this code C ? i can wait thank you very much

–

i really far away from C so i couldnt work it i tak this error; A namespace can only contain types and namespace declarations (lines 1 2 3 5 7 8 16 23 44.)

–

Thank you for your question and reply, it guide me here, it works fine in unity5.4.0 intergate with my app.

Yes this is in C# but the logic behind it is still the same as it would be in java, I edited my last post

–

@xpkoalz

Any idea how to do it with Android?