Make Main Camera Transparent

Is there any way to set the background of the main camera to be transparent?Maybe this is insane, but as a first proof of concept for a project I am working on, I would like to have the 3D objects created in Unity display on top of an interface created with interface builder. Basically, have the Unity engine run in a subview layered on top of a root view, creating the illusion that the 3D objects are on top of what is presented in the root view. I realize this would require tinkering in XCode after building with Unity, I’m not so worried about that. What I think is key is being able to have a transparent main camera background rather than a skybox or a solid colour. Possible???

If the camera Clear Flags = Depth Only does not work, then I guess it’s not possible. Just a guess

I guess that when working in x-code, you’ll have to define the unity background color as alpha color in some way so to subtract what you dont need…

I’m pretty sure this won’t work. You can’t layer a window of UI elements under an EAGLView. For one thing, the EAGLView isn’t transparent. Best you could do is maybe keep the Unity OpenGL view offscreen and blit its contents into a custom view in your interface. Getting the bits would be easy enough; you’ll have to pick a color to be transparent and avoids its use otherwise in the scene (don’t forget to flip the bitmap when you blit it). Keeping the Unity view offscreen might have some other impact on the engine, so test early.

I had tried this already and unfortunately, it isn’t that easy :cry:

This approach sounds promising. I’m going to investigate this further and attempt it. My major concern is the impact this might have on performance. And yes, I will be testing early. Since this is rather unconventional, I’m starting by just building a simple prototype to test the concept before I even begin to work on the game itself. At this point, I’ll be happy if I can successfully transpose a simple model from the Unity Engine onto the root UIView.

Out of curiosity, has anyone else attempted this? Have any successes or failures to report?

I’ve done some similar things. The enhancement pack displays UI elements over the top of the Unity engine display, and pulls the bits out for capturing screen grabs. And I’ve hacked the engine obj-c all to hell. Email me (rob at stinkbot.com) if you need help.