Multiple variables in Debug.Log

I'm not sure this is possible in Unity, but I would like to get something like this working:

Debug.Log("Mouse position", moveDirection, "Char Position", playerPosition);

I tried this code and it wouldn't allow it. I get the error "No appropriate version of 'UnityEngine.Debug.Log' for the argument list '(String, UnityEngine.Vector3)' was found"

You just need to concatenate them into one string:

Debug.Log("Mouse position: " + moveDirection + "   Char position: " + playerPosition);

And heck, because Eric beat me to it, you can also use string.Format if you want to use a parameter list:

Debug.Log(string.Format("Mouse Position: {0} Char Position: {1}", moveDirection, playerPosition));

Use this instead:

Debug.Log("Mouse position " + moveDirection + " Char Position " + playerPosition);

Now you can use Debug.LogFormat.

Example:

Debug.LogFormat("I have {0} apples.", 10);

my Log script:

using UnityEngine;
using System.Collections;

public class Log : Object {

public static void Trace(params object[] v){
	string o="";
	for ( int i = 0; i < v.Length; i++ )
	{
		o	+= ",";
		o	+= v*.ToString();*
  •   }*
    
  •   Debug.Log(o);*
    
  • }*
    }
    ==========================usage
    Log.Trace(this,33,918);
    ================
    mail me with any problem:leef918@gmailc.om

This class saved me a lot of time while debugging!

using System.Text;
using UnityEngine;

public class Puts
{
    public Puts(params object[] args)
    {
        var sb = new StringBuilder();
        foreach (var arg in args)
            sb.Append(arg).Append(" ");
        Debug.Log(sb.ToString());
    }
}

Usage: new Puts("hello", 123);

Visual Studio shows warning on this line - so I will not forget to remove this puts after finished debugging problem