我正在尝试使用Unity中的Debug.Log
调用来记录有关上下文的更多信息,以便将EXP系统中的代码调试到我的统一游戏中。
我试图传递所有与String.Format
类似的参数,但正如预期的那样出现了错误,如:
“没有重载方法'Log'采用'3'参数
如何记录其他详细信息以及消息?
代码:
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);
}
答案 0 :(得分:1)
确实Debug.Log只覆盖了1和2个参数(脚本API):
public static function Log(message: object): void;
public static function Log(message: object, context: Object): void;
您可能希望使用String.Format
来构建消息:
Debug.Log(string.Format("Our character starts at {0} xp and is level {1}.",
xp.GetCurrentXp(), xp.GetCurrentLevel()));