Page 1 of 1

disconnect navigation to DialogueSystem buttons

Posted: Sun Jan 10, 2021 4:14 pm
by fkkcloud
Hi,

during the conversation, I pop up a new UI with 3 buttons.

In order to let the event focus to be only on this pop up, I do below.

Code: Select all

PixelCrushers.UIPanel.monitorSelection = false;
eventSystemModule.GetComponent<EventSystem>().SetSelectedGameObject(null);
eventSystemModule.GetComponent<EventSystem>().SetSelectedGameObject(firstButtonGameObjectInPopUP);
Its good that the dialoguesystem don't get visible input yet but as I go down the list of 3 buttons then on 4th input, it selects the DialogueSystem's response Menu button (since I initiated pop up during response menu)

Is there any way to safely toggle the DialogueSystem's button/UI during conversation without changing its state too much so I can easily resume to conversation as this pop up UI goes away?

Re: disconnect navigation to DialogueSystem buttons

Posted: Sun Jan 10, 2021 6:03 pm
by Tony Li
You must set your 3 buttons' Navigation so the user can't navigate away from them.

Re: disconnect navigation to DialogueSystem buttons

Posted: Sun Jan 10, 2021 6:03 pm
by fkkcloud
They are dynamically instantiated on runtime

Re: disconnect navigation to DialogueSystem buttons

Posted: Sun Jan 10, 2021 7:14 pm
by fkkcloud
I just manually set the navigations I think this'd do the job

Code: Select all

public void SortNavigation()
    {
        for (int i = 0; i < buttons.Length; i++)
        {
            AssignNavigation(i, buttons[i].button);
        }
    }

    private void AssignNavigation(int i, Button button)
    {
        Navigation nav = button.navigation;
        nav.mode = Navigation.Mode.Explicit;
        
        int upID = i - 1;
        if (upID > -1)
        {
            nav.selectOnUp = buttons[upID].button;
        }

        int downID = i + 1;
        if (downID < buttons.Length)
        {
            nav.selectOnDown = buttons[downID].button;
        }

        button.navigation = nav;
    }

Re: disconnect navigation to DialogueSystem buttons

Posted: Sun Jan 10, 2021 8:37 pm
by Tony Li
Hi,

Yes, that's correct. That's what the Dialogue System does, too, when it instantiates response buttons into the response menu.