Forum rules - please read before posting.

Enable or disable Subtitles menu

Hi, I am new to this forum and, I apologize for my English, I will try to make you understand as much as possible. I wish I could enable or disable the Subtitles menu when the H key on the keyboard is pressed. I tried searching on the forum, but couldn't find anything that could help me. I think it is not possible to do this via ActioList, so I will have to use a script, the only problem is that my knowledge of C # is very low. So my question is this:
Is it possible to disable the Subtitles menu via script?
If it is possible, is there anyone who can give me an example?

Comments

  • Hi and welcome,

    You can do this with Active Inputs. See this video for how to use them:

    Trigger an Action List which uses the menu: change state node.

  • Welcome to the community, @karakas.

    Yes, active inputs are the way to go - see the Manual's "Active inputs" chapter as well as the video linked to above.

    Bear in mind that the named you enter into the Active Inputs window refers to the input you define in Unity's Input settings (Edit -> Project settings -> Input) - not the input key itself (e.g. H). "H" would instead be entered into Unity's Input settings as the "Positive button" field.

    The default subtitles menu will show when speech is played, but if a menu is locked then it will remain off at all times. In the ActionList asset that runs when the Active Input it pressed, you can first check to see if it's locked, and then unlock/lock it accordingly. This can be done with the Menu: Check state and Menu: Change state Actions respectively:

    Also know that, for testing, you can run an ActionList asset by clicking "Run now" in its Inspector at runtime.

  • Thanks for the reply, but this method doesn't work for me, these are the steps I did:
    1) Edit -> Project settings -> Input added a new input and I called it hide, in the positive button I put h
    2) Created an Active input in AC:
          Label: Hide
          Input button: hide
          Enable by default: checked
          Aviable when game is: Normal
          ActionList when triggered: ActiveInput_Hide
    3) The associated ActionList is identical to the one you posted in the image

    But when I press the h key the subtitles menu remains visible and nothing happens.

    I also tried putting Enable by default: unchecked and adding ActionList when turn on and ActionList when turn off whit:
    Input: Toggle active > Hide > checked for ActionList when turn on
    Input: Toggle active > Hide > unchecked for ActionList when turn off
    like it's in the video, but even so the subtitles menu remains visible

  • Try running the ActionList manually in the way I mention above - does it then work? We'll need to see if the issue is with the input, or the ActionList.

    Are you using the default AC interface, so that your subtitles are coming from a menu named "Subtitles"? Do any messages appear in the Console?

  • Sorry, I forgot to write it in the previous message, I also tried running the ActionList manually, but nothing happens. I use the Unity UI prefab.
    I tried to find an alternative solution, taking inspiration from this tutorial: https://adventurecreator.org/tutorials/calling-custom-events
    I created the following script:

    public AC.ActionListAsset attivateSubtitles;
    public AC.ActionListAsset disableSubtitles;
    public AC.ActionListAsset hideSubtitles;
    
    private void OnEnable()
    {
        //EventManager.OnMenuTurnOn += OnMenuTurnOn;
        EventManager.OnStartSpeech += IniziaSpeech;
        EventManager.OnStopSpeech += FermaSpeech;
    }
    
    private void OnDisable()
    {
        // EventManager.OnMenuTurnOn += OnMenuTurnOn;
        EventManager.OnStartSpeech -= IniziaSpeech;
        EventManager.OnStopSpeech -= FermaSpeech;
    }
    
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.H))
        {
            hideSubtitles.Interact();
        }
    }
    
    void IniziaSpeech (AC.Char speakingCharacter, string speechText, int lineID)
    {
        //Debug.Log("Character:" + speakingCharacter + ", text:" + speechText + ", LineID:" + lineID);
        attivaSubtitles();
    }
    
    void FermaSpeech(AC.Char speakingCharacter)
    {
        disattivaSubtitles();
    }
    
    public void attivaSubtitles()
    {
        attivateSubtitles.Interact();
    }
    
    public void disattivaSubtitles()
    {
        disableSubtitles.Interact();
    }
    

    Then I put the subtitles menu Appear type: manual, and I created the following ActionLists:
    Activate Subtitles: Menu: Change state > Turn On Menu > Subtitles
    Disable Subtitles: Menu: Change state > Turn Off Menu > Subtitles
    HideSubtitles: Menu: Check states > Menu is Visible > Subtitles
    if the condition matches Menu: Change state > Turn Off Menu > Subtitles
    else Menu: Change state > Turn On Menu > Subtitles
    In this way it works perfectly.
    However, I have to ask another question, in some scenes I use the third person cam, giving the possibility to rotate and zoom, but when it is active, even if the subtitles menu is invisible the camera cannot be rotated and cannot zoom. Is there a way to leave the cam free?

  • AC's third-person camera is not controllable during cutscenes (though I will see about making this optional). Whether or not subtitles are displayed, if the ActionList that is calling the speech is blocking gameplay, then camera input will still be displayed.

    You can prevent an ActionList from blocking gameplay by setting its When running field to Run In Background.

  • Thanks for the advice and, I know the Run In Background function, but unfortunately when you use that function the speech advances automatically and, for my type of game setting, it must be the player to advance the speech by clicking with the left button of the mouse or space.
    So if there are no other ways, I will have to replace it with a SimpleCamera

  • As for the first problem I had requested the solution, I think I understood where the anomaly was:
    When you use Lock Menu, the menu does not disappear if it is already visible, but it is only blocked and, in my case being the subtitles menu, remains visible but is blocked, so by continuing the subtitles menu disappears and no longer appears being blocked.
    So everything worked correctly, it just wasn't what I expected, I needed the menu to disappear immediately when H was pressed.

  • So if there are no other ways, I will have to replace it with a SimpleCamera

    The ability to rotate the third-person camera during cutscenes will be an option in the next AC update.

    in my case being the subtitles menu, remains visible but is blocked, so by continuing the subtitles menu disappears and no longer appears being blocked.

    As you were talking about the Subtitles menu, I was assuming its Appear type was set to its default value of When Speech Plays - in which case, locking should turn it off if this condition is currently met.

    If, however, your Menu's Appear type is set to Manual, then you will need to explicitly turn it off with the Menu: Change state Action. Locking it would only be necessary if you want to ignore subsequent calls to turn it back on.

  • The ability to rotate the third-person camera during cutscenes will be an option in the next AC update.

    Good news, then I leave the third-person cam, but I block the rotation, so when you release the next update I just have to unlock the rotation and ability the new option. Thank's for your job

    As you were talking about the Subtitles menu, I was assuming its Appear type was set to its default value of When Speech Plays - in which case, locking should turn it off if this condition is currently met.

    Yes, I tried both with the Active input and with a costum script:

    public AC.ActionListAsset hideSubtitles;
    
    void Update()
        {
            if (Input.GetKeyDown(KeyCode.H))
            {
                hideSubtitles.Interact();
            }
        }
    

    both activated the same Asset ActionList, identical to the image you posted to your first post, and the menu was set to its default value of When Speech Plays.
    When I push the H button the menu does not disappear, it remains visible until I skip the speech, then in this case the subtitles menu disappears and is no longer visible. If, on the other hand, the menu should disappear immediately, maybe I have something wrong, but I don't know what it could be

  • My mistake - locking will prevent subsequent lines from turning on the Subtitles menu, but you'll still need an additional Menu: Change state Action to turn it off after locking it.

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.