Page 1 of 1

Quest UI selected object issue

Posted: Tue Aug 29, 2023 8:12 pm
by gblekkenhorst
I am trying to program controller support for a menu. I have it set up so that selecting a quest from the Quest Selection Panel turns off that panel and enables the Main Content Panel. Then there is a back button to return to the previous menu.

I'm having the following issues:

1.
When the Quest has been selected from the quest selection panel, that quest button is set as EventSystem.current.currentSelectedGameObject, and seems to be stuck that was even though that button is now inactive and I am trying to use SetSelectedGameObject to change it to a different button. Is there something overwriting this selection? I can manually click on another button with the mouse but I can't toggle to different buttons from the controller.

2.

When I try to set the first task in the list as the current selection, it doesn't work.

I tried this:

Code: Select all

activeChildrenTasks = taskList.taskListContainer.GetComponentsInChildren<StandardUIQuestTitleButtonTemplate>();
            EventSystem.current.SetSelectedGameObject(null);
            EventSystem.current.SetSelectedGameObject(activeChildrenTasks[0].gameObject);
This method has worked for selecting the top object in other lists but in this case, the first several items in the list are always listed as "Missing".

Re: Quest UI selected object issue

Posted: Tue Aug 29, 2023 9:59 pm
by Tony Li
Hi,

Your quest log window probably has a Main Panel GameObject that has a UIPanel component. On the UIPanel component, set Refresh Selectables Frequency to a non-zero value such as 0.5. This will tell the UIPanel to check if any new Buttons have become navigable. Otherwise it will force the selection to be one of the buttons that it already knows about (the quest heading buttons and Active/Completed/Close buttons).

To select the first task, you'll need to make a subclass of StandardUIQuestLogWindow and override the RepaintSelectedQuest() method to something like:

Code: Select all

protected override void RepaintSelectedQuest(QuestInfo quest)
{
    base.RepaintSelectedQuest(quest);
    if (quest != null)
    {
        StartCoroutine(SelectFirstTask(quest));
    }
}

private IEnumerator SelectFirstTask(QuestInfo quest)
{
    yield return new WaitForEndOfFrame();
    StopAllCoroutines(); // Prevent another coroutine from changing UI selection.
    // *** set the selection to something else here ***
    // ** You can use UITools.Select(someButton); ***
}
I'm not quite clear on what taskList is, so I left a comment where you'd change the selection.