Unity characters on a Windows desktop

I'm trying to create a Unity project where I can have a character or object on the Windows 7 desktop with no background (i.e., the camera background is transparent).

Is there anyway to accomplish this in Unity?

This is really important. Thanks........

Every question is important to the one asking it.

This is a challenging problem. This is non-trivial regardless of Unity and I would say that question extends beyond the scope of Unity and UnityAnswers and belongs more within Windows development forums as a general question of how to make any application run without a background and allow interaction through the transparent areas of the application window - answer that and Unity, being an application like any other, can have that solution extended to it. My inclination is towards there not being a way, but if there is, I can at best speculate how it would be done.

There are really only about a two solutions that I can think of and neither is pretty:

  1. Continuously capture images of the desktop (without the application) to use as the application background. (How?)
  2. Hook into the Windows 7 Device Window Manager through an API to take advantage of Desktop composition, etc. Using Aero and glass themes, etc., it might be possible.

In theory, it might be possible to get into the actual graphics device and render your application on top before it puts it to the screen, but I have no idea where to even start with that. That's some pretty fancy DIrectX stuff beyond my depth, but from my understanding of the way the render pipeline works, that's likely not going to be a workable solution.

For any of these, you will have to do it through some code external to Unity. You could author a plug-in (Pro Only) and call functions there to make it possible inside Unity or you could author a program which starts the Unity application, gets the output of Unity without having it render to the screen (is that even possible? Maybe through a plug-in or shader which passes it out?) and does the compositing for you. Essentially you'd want to have the output rendered to some sort of back-buffer(conceptually anyhow) which you would then key (with chroma or if you can get out an alpha channel) to blend onto the back-buffer of the graphics device before it puts it to the screen.

Hooking into the DWM is not fun, but it is likely your best bet. I can recommend looking into the Windows API, but that is guaranteed to need a plug-in or external app as I believe as Unity mono doesn't support namespaces and I'm certain that API isn't packaged with mono.

Next is the problem of if you wanted to actually interact with the desktop while the application was running and I have no clue about this one. Your guess is as good as mine. If you could somehow bypass creating any sort of application window (starting in stead a background process or service) which would hook into the graphics pipeline without going through Windows' window manager, Conceivably, you could interact right through whatever you were pushing to the screen, but then you couldn't interact with what you were pushing to the screen unless your process was tracking the input as well. In any case, this is well beyond Unity.

I don't think you can easily use Unity for this. I imagine you could also try to write out a sequence of images with transparency (keying again if needed), .gifs or pngs or some such, which would require rendertextures (pro-only) and plug-in if needed, but bear in mind that this will really slow down your frame rate A LOT. If you have an application which drives the Unity standalone, it would have to read input on its own and feed the results to Unity, get the images that Unity outputs and draw them on the screen, using the alpha somehow. If the input is on the alpha area, using the DWM or Windows API or something, you may be able find out what's underneath or and trigger the appropriate action. If you're going this way, you'd be better off just rendering your image sequences as .gifs or movies or some such in advance and writing a custom application to do the work of dealing with input and drawing on the screen.

No. All Unity games run in a standard windowed or DX/OpenGL fullscreen environment. It's not possible to have a windowless, borderless DX/OGL application that's also transparent running on your desktop (in fact, I don't even think DX/OGL is capable of this as of right now).