I have an input fields array, after clicking on the button, a check for emptiness will be performed, I wrote the code, but an error occurs: "Syntax error; value expected". Please tell me how to solve this problem?
public InputField[] InputFields;
public void Done()
{
if (InputFields[].Text.Length == string.Empty)
{
Debug.LogFormat("Empty!");
}
}
CodePudding user response:
You need to loop through all the elements of your array
public InputField[] InputFields;
public void Done() {
foreach (InputField inputField in InputFields) {
if (string.IsNullOrEmpty(inputField.text)) {
Debug.LogFormat($"{inputField.name} field is Empty!");
}
}
}