我正在尝试在 Unity 中使用 Debug.Log
调用来记录有关上下文的更多信息,以将 EXP 系统的代码调试到我的 unity 游戏中。
我试图传递所有类似于 String.Format
的参数,但正如预期的那样出现了如下错误:
"No overload method 'Log' takes '3' arguments
如何记录消息的其他详细信息?
代码:
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);
}
最佳答案
确实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()));
关于c# - 使用 Debugger.Log 调用记录附加信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27370488/