- Home /
Detecting new lines in .ToCharArray
I have a small script that takes a string and turns it into an array of chars via the .ToCharArray function. Works like a dream. Except that I'm having trouble figuring out how to detect a new line character.
By example, if I have the following string: "hello every nice to meet you"
There's a newline after "every". If I Debug.Log() that char, it shows up as " ", the same as a space. I tried this: if(stringAsCharArray[charIndex].ToString() == System.Environment.NewLine)
but that doesn't seem to pick it up, either.
What's the best way to figure out if a char is actually a newline character?
Answer by Altamash · Jan 01, 2017 at 08:29 AM
@scottstephan I was facing a similar. here is i found the solution
function printTest(){ testString = " 1\n 2"; var i:int; %|1720899892_3|% for(i = 0; i < c.Length; i++){ %|293286007_5|% Debug.Log("new line"); } %|-415039016_8|% }