Hey everyone, I'm just started to learn C# for Unity and I'm a bit confused with a little problem. You see, I have learn a bit of Python before, and every single thing I want to interpretate is firstly coming in a form of a Python script ; I can't think with C# syntax yet. So, the thing I was thinking about was making a little text engine to display dialogues. The first thing I thought about was using coroutines, because I wanted each letter (or word) to appear at the screen with a delay, well, like in an average dialogue window. So I started with: // using System, public class MonoBehaviour blah-blah-blah
// in theory the script will be bound with an object activator already
private void OnMouseDown()
{
StartCoroutine(FirstDialogue());
}
IEnumerator FirstDialogue()
{
//and here comes the problem
}
So, what I would do in Python:
dialogueText = “Hello”
dialogueText.split("")
And the outcome would be an array of individual letters (and spaces if were some in the Text):
>>> ["H", “e”, “l”, “l”, “o”]
With that given array it would be much easier to create a cycle within that coroutine, so that I wouldn't write that:
IEnumerator FirstDialogue() // I will use just ‘print’ for example
{
print("H");
yield return new WaitForSecond(0.2f);
print("e");
yield return new WaitForSecond(0.2f);
print("l");
yield return new WaitForSecond(0.2f); //and so on…
}
So is there any way to make it easie, or should I just try to code a solution for myself? For me it's pretty challenging to code, I'm doing more stuff in 3D Modelling (Blender).