【问题标题】:How to print ********** in a single line by using Debug.Log() in MonoDevelop, a Unity 3D, 2D editor如何在 Unity 3D、2D 编辑器 MonoDevelop 中使用 Debug.Log() 在一行中打印 **********
【发布时间】:2017-08-26 19:29:11
【问题描述】:

我要打印

*****
*****
*****
*****
*****

通过使用 monoDevelop 的 Debug.Log() 在统一控制台中使用 for 循环。这是我的代码:

for(int row=1;row<=5;row++)
{
  for(int column=1; column<=5;column++)
     {
         Debug.Log("*");
     }
}

但它以这种方式显示输出:

*
*
*
*
*
till 25 rows. 

【问题讨论】:

    标签: c# unity3d unity5 monodevelop unity3d-2dtools


    【解决方案1】:

    Debug.Log() 的每次调用都是一个新行

    如果你想记录一行任何东西,你需要将它连接成一个字符串,然后Log()那个字符串。

    for(int row=1;row<=5;row++)
    {
        string str = "";
        for(int column=1; column<=5;column++)
        {
            str += "*";
        }
        Debug.Log(str);
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多