Forum rules - please read before posting.

changing 'Display subtitles forever until user skips it?' via script

Hey, I'm working on some accessibility features at the moment and one tester who is a non-native English speaker has requested the option for subtitles to stay on screen until skipped.

I don't really want this to be enabled by default as it will mess with the pacing for cutscenes with speech files.

is there a settingsManager function I can call to toggle the 'Display subtitles forever until user skips it?' checkbox? I was unable to find it in the scripting guide.

Thanks!

Comments

  • Never mind, I was being dim, I should have been looking at the SpeechManager attributes, not SettingsManager.

    I needed to call this: https://www.adventurecreator.org/scripting-guide/class_a_c_1_1_speech_manager.html#a6209c9af84404cbf41964f9874826c31

    And for anyone who finds this thread in the future, here is a small script I made:

    using UnityEngine;
    using AC;

    public class ACToggleSubtitles : MonoBehaviour
    {
    //This variable holds a reference to the Speech Manager
    private SpeechManager speechManager;

    //Start is called before the first frame update
    void Start()
    {
        // Get the Speech Manager from the AC's KickStarter
        speechManager = KickStarter.speechManager;
    }
    
    // Function to toggle the 'Display subtitles forever until user skips it' option
    public void ToggleSubtitlesForever()
    {
        if (speechManager != null)
        {
            // Toggle the boolean value
            speechManager.displayForever = !speechManager.displayForever;
    
            // Optional: Print the current state to the console for debugging
            Debug.Log("Display Subtitles Forever: " + speechManager.displayForever);
        }
        else
        {
            Debug.LogError("Speech Manager not found!");
        }
    }
    

    }

    I simply put this script on an empty game object in my Options Unity UI prefab, make sure the Options menu has a toggle button (and linked to AC menu manager), then under the Toggle's 'On Value Changed (Boolean)' event I drag in that game object with the script and navigate on the drop down to ACToggleSubtitles - ToggleSubtitlesForever() function.

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.