-1

How to see Array or List in console tap?
Is there the way to see them in console tap?
I want Debug.Log(array) -> [1,2,3,4]

derHugo
  • 83,094
  • 9
  • 75
  • 115
222 2
  • 47
  • 1
  • 8
  • In general please use the correct tags! Note that [`[unityscript]`](https://stackoverflow.com/tags/unityscript/info) is or better **was** a custom JavaScript flavor-like language used in early Unity versions and is **long deprecated** by now. – derHugo Jul 19 '22 at 07:42

1 Answers1

0
for(int i = 0; i < array.Length; i++)
{
    Debug.Log(array[i]);
}

Almost the same for the list. Or if you need a single-line variant

StringBuilder sb = new StringBuilder();
for(int i = 0; i < array.Length; i++)
{
    sb.Append(array[i]);
    sb.Append(" ");
}
Debug.Log(sb.ToString());
Morion
  • 10,495
  • 1
  • 24
  • 33
  • 1
    why so complicated? [`string.Join`](https://stackoverflow.com/a/36614277/7111561) already solves this ;) For exactly OP's format: `Debug.Log($"[{string.Join(",", array)}]");` ([fiddle](https://dotnetfiddle.net/sVxXUV)) – derHugo Jul 19 '22 at 07:44