Forum rules - please read before posting.

Making a menu toggle dependant on another menu toggle for 'Sticky Subtitles'

I had someone who is an English second-language speaker comment that my game's subtitles were disappearing too fast for him to read. So, I went through some of the forum threads here and found one or two others looking for the same thing, as well as this 'Custom Options' tutorial:
https://adventurecreator.org/tutorials/custom-options

and with great help from Grok, got a 'Sticky Subtitles' toggle option which targets the AC.KickStarter.speechManager.displayForever option (called 'Display subtitles forever until user skips it?' option in the AC Dialogue settings) that keeps subtitles on screen until the user clicks, allowing the user all the time they want to read the subtitles.

(I was trying to think of a short term for 'Keep subtitles on screen until user clicks' and Grok came up with 'Sticky Subtitles', can't take credit for that)

It works well and as intended, but the only issue is when Subtitles toggle is set to OFF and Sticky Subtitles is set on ON, because then no subtitles are displayed but the user needs to click to progress after each dialogue voice line.

I'd like to know please if there's a way for the 'Sticky Subtitles' option to only be available is 'Subtitles' is 'ON' (maybe otherwise grayed out or hidden), or if 'Sticky Subtitles' can always be set to 'OFF' if 'Subtitles' is 'OFF'.

Comments

  • Btw this the script set on the PreFab that the toggle triggers

    using UnityEngine;
    using AC;
    
    public class CustomSubtitlesToggle : MonoBehaviour
    {
        public void Apply()
        {
            AC.KickStarter.speechManager.displayForever = AC.GlobalVariables.GetVariable("SubtitlesForever").BooleanValue;
        }
    }
    
  • You can add this to the script - replacing StickySubtitles with the name of your element - to have it only show when subtitles are enabled.

    void Update()
    {
        PlayerMenus.GetElementWithName("Options", "StickySubtitles").IsVisible = Options.AreSubtitlesOn();
    }
    
  • Hi Chris,
    Hope you had a good weekend.
    Thanks for the suggestion - it doesn't seem to work unfortunately.
    The 'Sticky Subtitles' option menu still shows even when 'Subtitles' are set to 'Off', and I'm still able to turn on 'Sticky Subtitles' with Subtitles 'Off', with the issue/effect in-game remaining the same.
    The element name in the Options menu is called 'StickySubtitles' like you've included.
    I've also tried changing the 'SubtitlesForever' Global variable from being stored in Options to None, with no difference.
    Some screenshots in case this helps:


    And the updated script 'CustomSubtitlesToggle.cs':
    using UnityEngine;
    using AC;

    public class CustomSubtitlesToggle : MonoBehaviour
    {
        public void Apply()
        {
            AC.KickStarter.speechManager.displayForever = AC.GlobalVariables.GetVariable("SubtitlesForever").BooleanValue;
        }
    
        void Update()
        {
            PlayerMenus.GetElementWithName("Options", "StickySubtitles").IsVisible = Options.AreSubtitlesOn();
        }
    }
    
  • Does it hide correctly if you back out of the Options menu and re-enter?

  • It doesn't, I did try that as that's what I thought might be the case (only hiding once the menu was closed and re-opened), but will test again when I have Unity open.

  • Hi Chris - I can confirm the Sticky Subtitles option does not hide after exiting the menu and going back in. Tested with a number of on-and-off options of both subtitles and sticky subtitles, triggering the player to say subtitles, etc.

  • Do any Warnings appear in the Console?

    Try adding a Debug.Log to the Update function:

    Debug.Log ("Subtitles on:" + Options.AreSubtitlesOn());
    

    Does it change to True/False depending on the Subtitles option?

  • Hi Chris, thanks for the suggestion. I'll try this and report back.

  • Hi Chris, thanks, I got around to trying this.

    When I added the Debug to the second part of the script, I got this when turning the Subtitles and Sticky Subtitles options on and off:

    When I added the Debug to the first part of the script, I got this:

    Even though the Option displays 'Pause Subtitles', the Menu name is 'StickySubtitles':

    Happy to try any other ideas if you have any thought please, but otherwise not a trainsmash if I can't get it to work.

  • Sorry for the trouble. You're certain there are no Actions that are affecting the visibility in e.g. the Menu's "ActionList when turn on" asset?

    Is there any improvement if you replace the Update function with the following?

    void Update()
    {
        var menu = PlayerMenus.GetMenuWithName("Options");
        menu.GetElementWithName("StickySubtitles").IsVisible = Options.AreSubtitlesOn();
        menu.ResetVisibleElements ();
        menu.Recalculate ();
    }
    
  • Hi Chris - thanks so much for trying to help me. Unfortunately not I'm afraid, still the same thing.
    I tried setting the StickySubtitles Element 'is visible' to 'off' initially in case that did anything, unfortunately not.

    In case it helps with context, the StickySubtitles is linked to a global boolean variable, and 'ActionList on click' for StickySubtitles runs an ActionList called 'UpdateSubtitlesToggle' ActionList which looks like the image below - I followed an AC website tutorial for this I think but forgot what exactly I did.

  • The event in the screenshot is referencing a prefab that has the script attached, and not referencing the script directly?

    The Sticky Subtitles checkbox's visibility is set by the script each frame. Unchecking "Is visible?" won't have an effect unless you remove it.

    Am I correct in recalling that you're using a custom options file handler? The state of subtitles is recorded in that.

    If this issue occurs with the default file handler, probably best for you to PM me your project, sans Library folder. I can't see what the issue is from these screenshots alone.

  • Ah yes, I forgot to mention - the Global Variable that the StickySubtitles is linked to, is stored in the Player's Options Data. Sure thing, thanks - I'll ZIP the project (sans the huge Library folder) and PM you.
    If you have trouble getting the project to play in Unity, it's probably because of the SteamManager on the PersistentPrefab that's wanting to connect to Steam when the game launches, either having the Steam client open or disabling that script should do the trick. Thank you Chris.

  • Thanks to Chris who helped me figure this out - I added the script below to the PersistentEngine Prefab, and it seems to work well. The 'Pause Subtitles/Sticky Subtitles' Options' visibility toggles On and Off depending on whether 'Show Subtitles' is turned On or Off.

    using UnityEngine;
    using AC;
    
    public class CustomSubtitlesToggle : MonoBehaviour
    {
        public void Apply()
        {
            AC.KickStarter.speechManager.displayForever = AC.GlobalVariables.GetVariable("SubtitlesForever").BooleanValue;
        }
    
        void Update()
        {
            var menu = PlayerMenus.GetMenuWithName("Options");
            menu.GetElementWithName("StickySubtitles").IsVisible = Options.AreSubtitlesOn();
            menu.ResetVisibleElements();
            menu.Recalculate();
        }
    }
    
  • I do have one more question about this please - while turning Subtitles to Off hides the 'Pause Subtitles' option, the Pause Subtitles might still be set to On, so what happens is the characters speak without subtitles but wait for a mouse click to advance.

    That's not terrible, but I do worry someone might not understand why that happens if the option is hidden.

    Is there any way to add to the code that turning the Subtitles to Off also turns the Pause Subtitles to Off?

    My PlanB is to rename 'Pause Subtitles' to something like 'Pause After Speech' and not auto-hide it.

  • Is there any way to add to the code that turning the Subtitles to Off also turns the Pause Subtitles to Off?

    Added to Update:

    if (!Options.AreSubtitlesOn()) AC.GlobalVariables.GetVariable("SubtitlesForever").BooleanValue = false;
    
  • Hi Chris, thanks for this. While this seems to work, I think it's only turning the Pause Subtitles to 'Off' when Subtitles is turned back on, so the character speaks a line without subtitles and then waits for a mouse click to progress even when the option is being hidden.

    I've changed the 'Pause Subtitles' to 'Pause Speech' and removed the hiding toggle script, I think I'm happy with this as it gives the player the option for subtitles on/off and pausing on/off.

    Happy to close this thread, thank you.

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.