GUI.TextArea, AutoTyping solution?

Hi, im creating my own crude dialogue system due to every other third party dialogue system being a piece of crap.

So i require a multi-line text area, which GUI.TextArea seems best for. Although i would like the text to slowly type out and possibly use a sound just like this script which uses guiText.text http://wiki.unity3d.com/index.php?title=AutoType

So my question is, is this possible to do with TextArea? If so, how? and if not, what are my alternative options?

Cheers, love this community! Help save my project!

This could be done with GUI.TextArea but would not be efficient given you would have to compose the string one letter at a time which would result in Garbage Collection. In addition this needs to be in OnGUI() which is called multiple times per frame. Furthermore, this is an input field so… basically no ideal but it could be done.

Or you could use TextMesh Pro which has a property called TextMeshPro.maxVisibleCharacters which can be controlled via script to do exactly what you want. Using this property is super efficient, does not generate any GC, gives you control over word wrapping (for multiple lines of text) and so much more.

Unfortunately, TextMesh Pro isn’t free but it also does so much more than just this example.

alt text

Here is a link to the TextMesh Pro forum thread where you can learn more about it and check out examples. Here is a link to a web demo that includes text that is revealed.

Code used to create the example above.

using UnityEngine;
using System.Collections;
using TMPro;

public class SandBox_03 : MonoBehaviour {

    private TextMeshPro m_textObject;
   
    private const string label = "This is an <#ffff00>example</color> of some text being <#0080ff>revealed</color> using TextMesh Pro.";

    void Awake()
    {
        m_textObject = gameObject.AddComponent<TextMeshPro>();        
    }

    // Use this for initialization
	void Start ()
    {
        m_textObject.text = label;
        m_textObject.enableWordWrapping = true;
        m_textObject.lineLength = 40;

        StartCoroutine (RevealText());
	
	}


    IEnumerator RevealText()
    {
        int currentCharacter = 0;

        while (true)
        {
            m_textObject.maxVisibleCharacters = currentCharacter % (label.Length + 1);

            currentCharacter += 1;

// Insert Code here to make the typing sounds as each character is revealed.

            yield return new WaitForSeconds(0.05f);

        }
    }

}