- Home /
How to take the text from a rich text input field and save each line into an array
Hello, I need help with transferring the input from an input field into a script and saving each line of text separately in an array. I have tried to do this with the .Split function, but It only saves the first line, so I end up with one slot in the array containing just the first line of text. This is no use. Please help. :D
Code :
public InputField inputField;
public string[] lines;
void Update () {
lines = inputField.text.Split ("/n" [0]);
}
Answer by Jessespike · Sep 08, 2016 at 06:15 PM
Don't think rich text is supported for InputFields. Either way, try this:
lines = inputField.text.Split ('\n');
Note the single quotes and backslash.
Your answer
![](https://koobas.hobune.stream/wayback/20220612092305im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How can I change the phrase "I am sure you are right." to "You are sure I am right."? 0 Answers
UI InputField text sometimes invisible? 1 Answer
Unable to change value of Input Field text component 1 Answer
change GUI InputField to TMP_InputField 0 Answers
.txt file to string[] brakes by line 1 0 Answers