PHP has a convenient var_dump
function, I haven’t been studying C # for a long time, the search methods didn’t work. Is there something similar here?
Console.Write ()
is not what you want. There Debug.Log ()
, although I don’t know if there is a difference
Answer 1
Here’s a method that will do what you want.
I did not check the code, I wrote from my head, so there may be errors.
Make it as an extension to the Debug class and you will be happy.
If bugs have crept in in the code, fix it keeping the logic.
public static void Logissimo (object obj)
{
string rez = typeof (item) .ToString ();
if (obj is IEnumerable)
{
rez + = "= & gt; {";
int count = 0;
for (var item in array)
{
Debug.Log ($ "[{count ++}] {typeof (item)} = & gt; {item}; \ r \ n");
}
rez + = "}";
}
else
rez + = $ "= & gt; {obj}";
Debug.Log (rez);
}