Displaying dialogue text one character at a time


#1

Hello, I was directed here by Leslie with regards to figuring out a way to get dialogue text to display one character at a time instead of all at once. I have read through some of the threads that deal with this subject but it seems a consensus has yet to be reached on the subject.

I have tried tinkering with Vinoma’s source via VinomaEngine\VinomaDialogueController.cs as well as utilizing the Vinoma Scripts feature but to no avail… my knowledge of C# is not too great but I would like to learn more and improve. I have tried a route I am more familiar with by attaching a custom script directly to the VinomaGUI Dialogue Text Component–the code I have tried is attached. It doesn’t seem to have any effect but if I place this.GetComponent<Text>().text = currentText within Update() a change is noticeable but not satisfactory.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class TextAnimate3 : MonoBehaviour
{
    public float delay = 0.5f;
    Text fullTextComp;
    public string fullText;
    private string origFullText;
    private string currentText = "";

    // Init
    void Start()
    {
        fullTextComp = GetComponent<Text>();    // Get the attached Text Component
        fullText = fullTextComp.text;           // Set string to currently active text
        StartCoroutine(ShowText());
    }

    void Update()
    {
        
    }

    IEnumerator ShowText() // Used for displaying dialogue text one character at a time
    {
        for(int i = 0; i < fullText.Length; i++)
        {
            currentText = fullText.Substring(0, i);
            this.GetComponent<Text>().text = currentText;
            yield return new WaitForSeconds(delay);
        }
    }
}

Just being pointed in the right direction would be greatly appreciated! Thanks :smiley:


(Leslie Young) #2

I think best way to deal with it would be to have a proxy/middle man like you sort of have with the script above.

Feed TextAnimate3 the dialogue text and let it update the actual Text field.

The easiest way to deal with all of it would be if I can update the Dialogiue controller to send text to such a proxy rather than the original Text field.

I am going to add that change and then update this thread with the info… brb.


(Leslie Young) #3

Decided to add the effect myself. See updated docs for Dialogue action http://www.plyoung.com/vinoma-actions.html#dialogue

Also, see these docs if you want to add your own effect. http://www.plyoung.com/vinoma-advanced.html


#4

Very nice! A great tool has been made even greater! Thanks so much for your work :smiley:

I’ll have a look at the source myself to see what you did so I can learn–I also really appreciate the added functionality to facilitate modifying the text further.

Vinoma has been a lifesaver for me–thanks again!


#5

Thought this might be a better place to post this, rather than starting a new thread. The typewriter effect is very much appreciated, really adds a nice dynamic to text. One of the things I noticed though is current behavior acts differently than most visual novels. Clicking during the effect currently causes the dialogue box to skip to the next vinoma action, however, in most games clicking during the effect finishes loading the text of the current dialogue immediately, and proceeds to the next action on a second click.

Another user posted a script that implemented this, but it didn’t quite do the trick. This behavior would be really nice to have, though. Just thought I’d mention this incase you end up tinkering around with things, I understand Vinoma is feature complete, and I know you have other priorities. :slightly_smiling_face: