Skip to content

Console Log: in Unity

Hüseyin Tuğrul BÜYÜKIŞIK edited this page Apr 15, 2017 · 3 revisions

Unity game engine uses its own Debug.Log so Console.Write needs to be redirected to that method.

This is simply done with a class derived from TextWriter as being instructed here:

http://jacksondunstan.com/articles/2986

as seen in the article, only these methods(and 1 property) are needed to be overridden:

public override void Flush()
public override void Write(string value)
public override void Write(char value)
public override void Write(char[] value, int index, int count) 
public override Encoding Encoding 

Even if this works, Unity's console window doesn't show immediate output, but only shown when user clicks a row. Also outputting performance log to console is slow. Disabling "performance report" decreases a good amount of iteration latency.