Render to texture without a display.

I have a game that currently runs as an exe on a windows box. My game currently opens a socket to listen for requests, it then takes these requests, loads an asset, takes a screen shot of it using a RenderTexture, then saves the image. This all works great when I run my game in normal fashion, i.e., running it as a windowed app. What I would like to do is have my game run in the background as a windows service so that it is not accidentally closed and is auto restarted when the box is rebooted.

I’ve installed my exe as a windows service using the “sc create” command. When I start the service I get the following error in the unity standalone log file:

IndexOutOfRangeException: Array index
is out of range. at
UnityEngine.Display.RecreateDisplayList
(System.IntPtr nativeDisplay)
[0x00030] in
C:\BuildAgent\work\d63dfc6385190b60\artifacts\StandalonePlayerGenerated\UnityEngineDisplay.cs:95
(Filename: C Line: 0)

desktop: 1024x768 60Hz; virtual:
1024x768 at 0,0 Switching to
resolution 1024x768 failed, trying
lower one All resolution switches have
failed Screen: DX11 could not switch
resolution (1024x768 fs=0 hz=0)

I believe this is due to the fact that when my game runs as a service there is no display window. I would prefer to not have a window so it doesn’t get closed by accident, and since there is no user interaction, it just gets in the way.

Is it possible to render to an image without the game window open?

I’m using Unity Pro 4.6.

Check this out:

-batchmode might do the trick.