Forum rules - please read before posting.

Scrolling DialogLists with Gamepad Input

Hey Chris,

AC v1.83.0
Unity 2022.3.8f1

I'm currently struggling with an issue while setting up my gamepad controls. I can't seem to get the DialogList to shift to the next DialogOption once the last slot is reached. I managed to make this work with the InventoryBox, but the same approach doesn't seem to transfer to MenuDialogList.

I'd prefer not to rely on a button/arrow that the player has to select manually. I'm using the DialogList both for Conversations and for an Objectives list.

AC.KickStarter.menuManager.keyboardControlWhenDialogOptions = true
AC.KickStarter.menuManager.keyboardControlWhenPaused = true

The menu itself is a Unity UI prefab. I've also included links to some images.

https://imgur.com/a/MDJTILq

An excerpt from my InventoryScroll Script.

private int GetNextValidIndex (System.Collections.Generic.List instances, InvInstance selectedInstance, int direction)
{
if (instances == null || instances.Count == 0)
{
return -1;
}

int startIndex = -1;
if (InvInstance.IsValid(selectedInstance))
{
    startIndex = instances.IndexOf(selectedInstance);
}

if (startIndex < 0)
{
    if (direction > 0)
    {
        for (int i = 0; i < instances.Count; i++)
        {
            if (InvInstance.IsValid(instances[i]))
            {
                return i;
            }
        }
    }
    else
    {
        for (int i = instances.Count - 1; i >= 0; i--)
        {
            if (InvInstance.IsValid(instances[i]))
            {
                return i;
            }
        }
    }

    return -1;
}

int count = instances.Count;
for (int i = 0; i < count; i++)
{
    int index = (startIndex + direction * (i + 1) + count) % count;
    if (InvInstance.IsValid(instances[index]))
    {
        return index;
    }
}

return -1;

}

I hope you can help me with this. I'm a bit stuck at the moment, and I assume others may have run into this problem before, but unfortunately I couldn't find anything about it in the forum.

Best regards,
Marco

Comments

  • For a more general approach, I'd say it's better to deal with the UI Button objects directly, as opposed to the AC content that they represent.

    If you set the When invisible field to Disable Object, then unused Buttons will be de-activated, allowing custom code to more easily check what options are available.

    As Unity Buttons have an Automatic option for their Navigation handling, what you could try is to instead let the Event System navigate between each Button automatically. For looping around when you press "up" on the first Button etc, add an invisible Button in that direction that - when the user selects it - forces selection of the visible button on the other end.

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.