Page 1 of 1

Fading dialogue text in

Posted: Thu Jan 30, 2025 8:32 pm
by F4iR
Hi there,

I'm not a big coder but got along pretty well with the dialogue system so far. I started with the WRPG Template with accumulated text in the panel.
Now I'm a bit stuck with integrating a fade in feature for new conversation lines. As far as I know, there is no pre-build feature for this in the package.

I tried creating a little script but in the current state I only got all of the conversation lines to fade in again every time the text changes. Is there a way to specify that I only want the newly created conversation line to fade in? Or is my approach completely wrong?

Best thing would be if I could use the fade together with the Typewriter feature. I experimented with the On Character function.

Code: Select all

using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using PixelCrushers.DialogueSystem;

public class Fade : MonoBehaviour
{
    [SerializeField] Text text;
    [SerializeField] float fadeTime = 1.0f;

    
    public void OnTextChange ()
    {
        StartCoroutine(FadeInCR(fadeTime, text));
    }
    
    public IEnumerator FadeInCR(float t, Text text)
    {
        text.color = new Color(text.color.r, text.color.g, text.color.b, 0);
        while (text.color.a < 1.0f)
        {
            text.color = new Color(text.color.r, text.color.g, text.color.b, text.color.a + (Time.deltaTime / t));
            yield return null;
        }
    }
}
Thanks and sorry if this is kind of a basic question.

Re: Fading dialogue text in

Posted: Thu Jan 30, 2025 9:05 pm
by Tony Li
Hi,

If it's in your budget, I recommend using Text Animator. It has built-in fading and much more.