- Home /
Help launching headless application?
Hey, I'm trying to do something that I assume is pretty basic - create a barebones Unity application and launch it in headless mode (server build) on OSX. Unfortunately, I'm pretty lost.
I have a new Unity (2019.2.2f1) file with a single game object in the scene, which has a script attached:
public class test : MonoBehaviour {
void Start() {
Check();
}
void Check() {
if (Application.isBatchMode) {
Debug.Log("In BatchMode");
} else {
Debug.Log("not in batch mode");
}
}
}
This works fine when running in Unity, and after building it as a Server Build targeted at Mac OX X, I have an .app file. The problem is, I'm not sure where to go from here. How do I actually run this file? And what should I expect as a result? Things I've tried:
Double clicking on the file... it'll launch, go into not responding mode, and close after a while
Running "open testbuild.app" from the terminal, same result
While Googling, I found the command line arguments. The first one simply opens Unity Hub; I'm not sure how you'd go about opening a specific Unity file. "testbuild.app --batchmode" and "testbuild --batchmode" return "command not found."
Following the steps here, I ran "chmod 755 testbuild.app" and then "./testbuild -batchmode", but got back an error saying that testbuild.app is a directory.
To make matters tougher, I'm not sure what kind of output I am expecting. I read that headless builds will save output in the Log files, but I didn't see anything relevant there.
I really appreciate the help. I've been trying to figure this out all day but haven't really made any progress.
Thanks in advance!
P.S. my overall goal is to eventually build a server that I can deploy on a VPS. After I get this working, My next step is launching a server when headless mode is detected.
Answer by markuskir · Feb 18, 2020 at 09:29 PM
Quick update in case anyone ends up stumbling across this in the future. It turns out that you had to right click on the file, select "Show package contents," locate the file under Contents > MacOS, and drag the executable file into the terminal.
Also, Debug.Log apparently won't work for logging messages to the terminal. A better solution would be to write an application that issues commands to the running server.