How to create new line in string from inspector?
public float delay = 0.1f;
public string fullText;
private string currentText = "";
void Start () {
StartCoroutine(ShowText());
}
IEnumerator ShowText () {
for (int i = 0; i < fullText.Length; i++) {
currentText = fullText.Substring(0, i);
this.GetComponent<Text>().text = currentText;
yield return new WaitForSeconds(delay);
}
}
When i put text into fullText string in inspector, it just does one line. I've tried putting \n where new line is needed, but it didnt help. I've also tried copying text from notepad with correct linebreaks, but it didnt do the thing either. Any ideas? Thx!
Answer by ErikHallmarkDev · Jan 15, 2017 at 10:25 PM
If I'm understanding the problem you're having, you should be able to fix it by adding the TextAreaAttribute to your fullText
string.
[TextArea]
public string fullText;
Out of all solutions i tried, this one was the simplest and it worked. Thank you!
Thank you very much for this ! It saved me too ! So I have a question about that : does the TextAreaAttribute takes more resources than a normal public string ?
Just adding on to the pile of "thank you" comments. I was struggling with this and here you offered such a quick and easy solution. Cheers!
Your answer
Follow this Question
Related Questions
How to get the active/loaded Scene then turn the name of it into a string? [C#] 1 Answer
LINEAR COLOR SPACE CAUSE ICONS TO BECOME DARKER NOT SOLVED 1 Answer
Inspector assigned variables not assigning in build 0 Answers
how to see if two string are the same (I just what to see if Magicsetom[x] is == to boxadd ) 2 Answers