Reputation: 113
I am trying to log more information about context using Debug.Log
call in Unity, to debug code an EXP system into my unity game.
I tried to just pass all arguments similar to String.Format
but as expected got errors like:
"No overload method 'Log' takes '3' arguments
How can I log additional details along with message?
Code:
void Main()
{
XP xp = new XP(1300);
Debug.Log("Our character starts at {0} xp and is level {1}.",
xp.GetCurrentXp(), xp.GetCurrentLevel());
Debug.Log("Now, we add 2000 xp.");
xp.AddXp(2000);
Debug.Log("Now, our character has {0} xp and is level {1}.",
xp.GetCurrentXp(), xp.GetCurrentLevel());
Debug.Log("Our character is {0}% in to his next level",
xp.GetPercentInToLevel() * 100f);
}
Upvotes: 2
Views: 248
Reputation: 304
Indeed Debug.Log only have overrides with 1 and 2 arguments (scripting API):
public static function Log(message: object): void;
public static function Log(message: object, context: Object): void;
You may want to use String.Format
to construct message:
Debug.Log(string.Format("Our character starts at {0} xp and is level {1}.",
xp.GetCurrentXp(), xp.GetCurrentLevel()));
Upvotes: 1