0
\$\begingroup\$

I am new to working with Unity3d, I need to navigate between several inputField, for this I have looked at the solution that is in: tab-between-input-fields, but always the FindSelectableOnUp() or FindSelectableOnDown() returns null, so my next is always null and always ends in: next = Selectable.allSelectables[0];

\$\endgroup\$
0
\$\begingroup\$

I did a small improvement to @virtouso answer. I start always with the first inputfield in my list and after the last inputfield I am reseting my counter to start again from beginning.

public  List<InputField> fields;
int _fieldIndexer;

private void Update()
{
    if (Input.GetKeyDown(KeyCode.Tab)) {
        if (fields.Count <= _fieldIndexer)
        {
            _fieldIndexer = 0;
        }
        fields[_fieldIndexer].Select();
        _fieldIndexer++;
    }
}


void Start () {
    fields = new List<InputField>{PreNameInput, FamilyInput, BirthdateInputField};
}
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

it seems you want to change **focus** between input fields by tab button. im not sure there is a builtin solution for this but you can simply write a code for this solution. for this you have to make a list for your input fields. then on Prees Tab Button change index and call Select function. this is my eample but you have to handle other things too:

     public  List<InputField> fields;
        int fieldIndexer;
        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.Tab)) {
 fieldIndexer++;
fields[fieldIndexer].Select(); 
}
        }
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

A possible cause for the FindSelectableOnUp and FindSelectableOnDown returning null could be the value set under Navigation. Each Selectable (InputField is a Selectable) has in its inspector a section called Navigation.

enter image description here

This influences what FindSelectableOnDown and FindSelectableOnUp return. If vertical is not checked for any of the 2 InputFields you want to link for instance, they won't be able to navigate to each other. (Also note, the visualize button should show arrows in the scene view if Navigation is enabled for both elements)

For more info about how Navigation works, see this section in the manual

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.