For example, I have a text file: small little girl lived in deep space. Her parents died, when she was three years old, since that time, she´s browsing space around her, finding new friends.
I need to spawn this text by words with one second delay…
it´s also can be done by creating new game object for each word, but i am sure, that it can be more easily…
it should works like this :
Small (1sec) little (1sec) girl (1sec)
lived(1sec) etc…
Thank you for answer
[SerializeField] private TextAsset _myTextAsset;
List words = _myTextAsset.text.split(" ").ToList();
And then run some sort of timer or coroutine over the words list storing current index.
Thank you… I tried to make it as you say, but i have a problem. is it possible to make a new text object directly from script? i am sorry, if my questions are stupid, i am new in unity, and i am working on one project and i try to learn it by way. for example… is little bit possible to make a script like this? i know some syntax is bad, but i think, you will understand, what i am trying to do…
List<string> words = _myTextAsset.text.split(" ").ToList();
public float distanceX; // space between words
public float distanceY; // space between lines
public float endOfLineMultiplier; // multiplier for word.length
public float endOfLineIdentifier; // identifying end of line
private float defaultYtransform;
private float defaultXtransform;
private float previousXTransform;
private float previousYTransform;
foreach string word in words // going throw list
{
private text = new TextObject;
text = word;
if (endOfLineIdentifier >= (previousXTransform + distanceX + word.Length * endOfLineMultiplier)) // if end of line != 1 write word to this line
{
text.Transform = (previousXTransform + distanceX + word.Length * endOfLineMultiplier, previousYTransform , 0)
}
else // if end of line = 1 , return to start of second line
{
text.Transform = (defaultXtransform,defaultYtransform + distanceY,0)
defaultYtransform = (defaultYtransform + distanceY)
}
Instantiate text;
Did you check Fully Flexible UI Text | GUI Tools | Unity Asset Store?
You can have each character as a separate UI Text and then changing it’s scale, position etc.