Forum rules - please read before posting.

How can I stop text scrolling sound when I skip scrolling?

I am using text scroll audio and my sound is 4 secs long. When I click once I display full text but sound keeps on playing.
I couldn't find any setting in speech sections. Is there one or should we stop via script?

Thank you.

Comments

  • Welcome to the community, @minddrawer.

    The sound assigned to the scroll-audio field is more intended for a single character - i.e. one very short that can stop naturally at the same time as scrolling ends.

    However, you can end it manually with the following script placed in the scene:

    using System;
    using UnityEngine;
    using AC;
    
    public class StopScrollingAudio : MonoBehaviour
    {
    
        private void OnEnable () { EventManager.OnEndSpeechScroll_Alt += OnEndSpeechScroll; }
        private void OnDisable () { EventManager.OnEndSpeechScroll_Alt -= OnEndSpeechScroll; }
    
        private void OnEndSpeechScroll (Speech speech)
        {
            AudioSource audioSource = null;
            if (speech.GetSpeakingCharacter () && KickStarter.speechManager.speechScrollAudioSource == SpeechScrollAudioSource.Speech)
            {
                audioSource = speech.GetSpeakingCharacter ().speechAudioSource;
            }
    
            if (audioSource == null && KickStarter.sceneSettings.defaultSound)
            {
                audioSource = KickStarter.sceneSettings.defaultSound.audioSource;
            }
            if (audioSource)
            {
                audioSource.Stop ();
            }
        }
    
    }
    
  • Thank u chris you are the best. My coworkers always say how well you coded AC.

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.