version is actually Unity 2023 but that’s not listed(?)
Hi all! Been wrangling a couple days with trying to get Unity to record a video of the game itself playing in editor for Unity Cloud Builds (the dream is a game that documents itself as one CI/CD element, and maybe uploads that to youtube). I have this all working locally in editor which is neat after fighting the Youtube API some and getting Unity Recorder starting and ending with an automated playthrough run by a CheatManager class I have, but this doesn’t work in batch mode (as I’m trying to reproduce UCB conditions locally). All I see is the build finishing, my PostBuildProcessor script starting the recording process, and then UnityEditor.EditorApplication:Internal_EditorApplicationQuit() killing the ADB server and everything else. The non-batch editor stays open and the game successfully plays through itself, saving a video, and then disabling Play mode.
So, what’s going on with batch mode in my build pipeline? Something seems to kill Unity automatically - which is just fine, except I need a way to delay that without just filling a while(…) loop since I need the main thread to actually play and record my game, not hanging/freezing on a single loop in the main thread. The recording won’t get made that way.
Is there any way to delay Unity batch editors from automatically closing when the build is done? I am using this command from batch build, so I assume removing -quit would do it here, but I want it working in Unity Cloud Build too where I won’t be able to control the CLI line that fires for running Unity.
Batch mode presents no GUI whatsoever and doesn’t render anything. What’s the Recorder supposed to capture in batch mode when there aren’t any editor windows?
Or do you mean something else, like launching the build and recording that? In that case, the Recorder won’t capture build output nor is it runtime-enabled. Recorder only captures editor windows.
The Recorder already captures more than is displayed in editor - you can have a tiny 320x240 display of the game but ask it to record a 4k video (by using RecorderSettings.ImageInputSettings.OutputWidth / Height), and it will successfully record and save a 4k video.
If that’s possible in Editor, I figured there was no inherent reason Recorder couldn’t have similar witchcraft in batch mode lol. So while not guaranteed, I figured it was at least worth asking. Is there any official confirmation that this would never work? I figured given the above that Recorder must just operate outside what is displayed in the usual Unity GUI, but I don’t know by how much. Afaik: Recorder was never capturing exactly what was displayed to begin with.
We can just reason about this. Common sense.
There’s nothing rendered in batch mode. Hence nothing to record. And this probably crashes because nobody tests the recorder operating in batch mode.
Sadly this appears to just be inaccurate - my gut seems to be right that the GUI is not a limitation on Recorder’s recording ability. Here are two relevant other links:
Screenshots in Headless Mode:
Recording without displaying to screen:
Both involve rendering to render texture instead of the screen, and it’s definitely trickier since it sounds like Camera.main is not always defined, but it looks like rendering to RT at least can be used to export to screenshots and worst case a series of screenshots to convert into a video later. I imagine Recorder can be tied in with this too, but we will see.
Glad to see rendering can exist in headless and no-graphics mode, just as complicated as I feared lol.
EDIT: and once I get this all working, I’ll circle back on the core question of whether exiting builds need delays or not still. But there’s no crash, btw? Maybe you confused that with the server getting intentionally killed.