Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by gstier · Jan 28, 2015 at 07:44 PM · windowsrendertextureservice

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.

Comment
Add comment · Show 6
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image mieszkomatkowski · Jun 23, 2015 at 12:40 AM 0
Share

Have you ever got this working? I am running into same issue and I am interested if Unity can be used to render textures from background windows service.

avatar image badgeir · Jun 27, 2016 at 05:41 PM 0
Share

Did you find a solution? i am looking for the exact same thing.

avatar image gstier · Jun 27, 2016 at 05:49 PM 0
Share

I never found a solution. I run my app on a remote server and have to remote desktop into it and restart the app whenever the box is rebooted.

avatar image badgeir · Jun 28, 2016 at 08:47 AM 0
Share

I actually found a solution after I posted here.

Do you run the standalone player in batchmode? (without display and user input) Running a standalone player in batchmode (cmdline): mystandaloneplayer.exe -batchmode

In order to render to rendertexture in batchmode, I found I had to manually render using mycamera.Render(); (with rendertexture as targettexture on the camera).

avatar image gstier badgeir · Jun 28, 2016 at 02:13 PM 0
Share

Are you sure you're app is using the GPU? I seem to remember doing something like this and the problem I had was the app wasn't using the GPU for rendering and ins$$anonymous$$d it was using a software renderer. Check the log file after you app is started and make sure you see something like the following:

 Version:  Direct3D 11.0 [level 11.0]
 Renderer: A$$anonymous$$D RADEON HD 6450 (ID=0x6779)
avatar image badgeir gstier · Jun 29, 2016 at 07:28 AM 0
Share

I think you're right. Speed is not an issue for me though, as I am not running a realtime app (I'm simply generating thousands of images for use in something else.)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Paulius-Liekis · Jan 28, 2015 at 08:43 PM

Check this out:

http://docs.unity3d.com/Manual/CommandLineArguments.html

-batchmode might do the trick.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image gstier · Jan 28, 2015 at 09:08 PM 0
Share

I tried this, the images that get created are just grey images. When running batchmode, Unity doesn't initialize the graphics pipeline at all. I believe batchmode is for running things like networking servers or build servers. I could be wrong though.

If I look at the output when running in batchmode I see something like this:

 Initialize engine version: 4.6.1f1 (d1db7a1b5196) Forcing GfxDevice: 4 NullGfxDevice:
     Version:  NULL 1.0 [1.0]
     Renderer: Null Device
     Vendor:   Unity Technologies


Compared to a normal start up, I see this:

 Initialize engine version: 4.6.1f1 (d1db7a1b5196) GfxDevice: creating device client; threaded=1 Direct3D:
     Version:  Direct3D 11.0 [level 11.0]
     Renderer: A$$anonymous$$D RADEON HD 6450 (ID=0x6779)
     Vendor:   ATI
     VRA$$anonymous$$:     1010 $$anonymous$$B
avatar image Paulius-Liekis · Jan 28, 2015 at 09:29 PM 0
Share

Documentation on -nographics implies that -batchmode should have graphics initialized.

You could also try forcing gl/dx, maybe that would help.

avatar image gstier · Jan 29, 2015 at 02:38 PM 0
Share

I too thought the -nographics would imply graphics, but when I run my app in batchmode my images are empty. When I force open gl I get a really long and weird stack trace that ends with "crash!!"...kind of funny.

avatar image Paulius-Liekis · Jan 29, 2015 at 03:33 PM 0
Share

You could try using Editor (in batch mode) to generate these screenshots. $$anonymous$$aybe it works better than standalone build...

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

22 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Render a Unity game as a texture in another Unity game on Windows 0 Answers

How to use a Render Textures Native Pointer in another process 0 Answers

Check If Service Is Running C#? 1 Answer

How can I get the RenderTexture OpenGL texture ID? 4 Answers

Command line to install Unity's cache server as a service on windows 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges