Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print ********** in a single line by using Debug.Log() in MonoDevelop, a Unity 3D, 2D editor

I want to print

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

by using a for loop in the console of unity by using Debug.Log() of monoDevelop. Here is my code:

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

But it shows the output in this way:

*
*
*
*
*
till 25 rows. 
like image 978
Muhammad Luqman Avatar asked Dec 05 '25 09:12

Muhammad Luqman


1 Answers

Each call to Debug.Log() is a new line

If you want to log a line of anything you need to concatenate it into a string, then Log() that string.

for(int row=1;row<=5;row++)
{
    string str = "";
    for(int column=1; column<=5;column++)
    {
        str += "*";
    }
    Debug.Log(str);
}
like image 130
Draco18s no longer trusts SE Avatar answered Dec 07 '25 22:12

Draco18s no longer trusts SE



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!