- Home /
Command line feedback
I am running a Unity Editor function from the commandline and I am looking to get feedback to the console/terminal instead of only the "Editor.Log" file. Basically anything that comes out of the Debug.log would be great, especially to see where things are failing.
I've tried the C# "System" but it seems to conflict with another Unity object.
Any suggestions? TIA.
Answer by pronebrid · Feb 19, 2013 at 07:37 PM
Empty -logFile option forces Unity to output log to console:
$UNITY_BIN -quit -batchmode -logFile -projectPath ...
This WILL work for people using OSX (I'm on Unity 4.2 using $$anonymous$$avericks). Does NOT work for Windows users (At least not on Windows 7).
Answer by capyvara · Aug 13, 2011 at 04:06 AM
This is what I've done as a workaround:
On Unix based system (such as OSX) you can create a shell script to monitor the Editor.log and output to the stdout, ex:
unity_stdout.sh
#!/bin/sh
tail -F ~/Library/Logs/Unity/Editor.log &
/Applications/Unity/Unity.app/Contents/MacOS/Unity "$@"
EXITCODE="$?"
kill %1
exit "$EXITCODE"
Usage:
./unity_stdout.sh -batchMode ...etc
It launches tail in monitor mode as a background task, launches Unity passing the command line arguments, store it's exit code, kills tail and return the saved exit code.
However all the Editor.log will be dumped, this include calls to Debug.Log() and Console.WriteLine().
If you want to choose what will be dumped to the console, instead open a file stream in Unity to some file like My.log, write to it and modify the shell script to monitor your file instead of the Unity.log
nice. ~/Library/Logs/Unity/Editor.log is exactly what i was looking for.
Answer by JBC · Jun 17, 2010 at 11:50 PM
actually Joachim Ante had a great answer that works from another answer:
string[] System.Environment.GetCommandLineArgs()
i can not imagine how this is relevant to the question at all.
@semiessessi I can easily imagine how he just didn't bother to actually read the question and gave a random answer
However I just noticed that he is actually the OP! So he didn't, umh, read his own question? This site is insane.
Well, compared with the SE network, this is an unmoderated mess. Community-driven sites do not work if the community isn't large enough for the design, and this desing implies needs many dedicated users that just aren't there.
Answer by Mike 3 · Jun 14, 2010 at 07:03 PM
try
System.Console.WriteLine(yourString)
if that doesn't work, you'll have to reroute the standard console output (only need to do it once):
System.IO.StreamWriter standardOutput = new System.IO.StreamWriter(System.Console.OpenStandardOutput());
standardOutput.AutoFlush = true;
System.Console.SetOut(standardOutput);
Then you can use System.Console.WriteLine(yourString);
this does not appear to be working for me. (windows btw) A good example of this is being used would be the DressingRoom example project where the commandline is: unity.exe -batchmode -quit -nographics -projectPath "C:\demo\characterdemo\unity" -execute$$anonymous$$ethod CreateAssetbundles.Execute but the gameObject is coded into the CS file.
In that case, not sure if there is a way to do it - it sounds like they've rerouted the standard out for mono, so no way to get at the console stream.