Unity Debug.Log with multiple arguments

Javascript has neat debugging function console.log that accepts multiple variables which makes easy to compose and modify debug output. It’s easy to do same kind of utility script for the Unity.

public class Console
{
    public static void Log(params object[] a)
    {
        var s =a[0].ToString();
        for ( int i = 1; i < a.Length; i++ ) {
            s += " ";
            s += a[i].ToString();
        }
        Debug.Log(s);
    }
}

Now it’s easy to write debug strings like this

var i = 4;
var a = "the";
Console.Log("Hello", i, a, "World");
// => "Hello 4 the World"

Instead of this crappy string concatenation..

var i = 4;
var a = "the";
Debug.Log("Hello " + i.ToString() + " " + a + "World");
// "Hello 4 theWorld" .. forgot one space :(