Forum rules - please read before posting.

Dialogue Line background texture transition problem

Hi fellow developers,

I searched a lot in the forums but couldn't find any solution to my problem.

I have long Dialogue Lines for my player speech, separated by carriage returns. I checked the "Treat carriage returns as separate speech lines?" option but this causes background texture to fade in and out for every line. Is it possible to keep the background texture still?

I made a tricky solution to show the background with another menu item but it doesn't seems to me that efficient.

Thanks for your help.

Comments

  • Welcome to the community, @Neslihan.

    Are you looking to have a delay between such lines? If not, you could try reducing the Split line delay (s) slider (which appears when Treat carriage returns as separate speech lines? is checked) to zero. This will remove any time-gap between lines, so that the Menu doesn't have a chance to transition out before a new line is begun.

    Otherwise, you can rely on a simple script to automate the display of the Subtitles menu. The menu's default Appear type is set to When Speech Plays, which will cause it to show/hide automatically at the moment lines are played and ended - without waiting to see what lines come next.

    If you set it to Manual, however, then you can command its display through script. If you still want it to be based on when speech start and stops - but only turn off after a delay - then you can hook into the OnStartSpeech / OnStopSpeech custom events, which fire at these times.

    Custom events are a way of running custom code when AC performs common tasks. A tutorial on their usage can be found here, but this script (CustomSubtitlesDisplay.cs) is one way you could use them:

    using UnityEngine;
    using AC;
    
    public class CustomSubtitleDisplay : MonoBehaviour
    {
    
        public string subtitlesMenuName = "Subtitles";
        public float afterDisplayTime = 0.5f;
        private float timer;
    
        private void OnEnable ()
        {
            EventManager.OnStartSpeech_Alt += StartSpeech;
            EventManager.OnStopSpeech_Alt += StopSpeech;
        }
    
        private void OnDisable ()
        {
            EventManager.OnStopSpeech_Alt -= StopSpeech;
            EventManager.OnStartSpeech_Alt -= StartSpeech;
        }
    
        private void Update ()
        {
            if (timer > 0f)
            {
                timer -= Time.deltaTime;
                if (timer <= 0f)
                {
                    PlayerMenus.GetMenuWithName (subtitlesMenuName).TurnOff ();
                }
            }
        }
    
        private void StartSpeech (Speech speech)
        {
            PlayerMenus.GetMenuWithName (subtitlesMenuName).TurnOn ();
            timer = -1f;
        }
    
        private void StopSpeech (Speech speech)
        {
            if (KickStarter.dialog.IsAnySpeechPlaying ())
            {
                return;
            }
            if (afterDisplayTime > 0f)
            {
                timer = afterDisplayTime;
                return;
            }
            PlayerMenus.GetMenuWithName (subtitlesMenuName).TurnOff ();
        }
    
    }
    
  • This is exactly what I was looking for. Thanks @ChrisIceBox for this very detailed answer. :)

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.