There’s probably some obvious/stupid reason, but for now my brain is not functioning. I am trying to check if a TMP inputfield component exists with the following code but am experiencing issues
bool checkTMPInput()
{
Debug.Log("===================> TEST FUNC 1 !!!!!! " + GetComponent<TMPro.TMP_InputField>() != null);
Debug.Log("===================> TEST FUNC 2 !!!!!! " + GetComponent<TMPro.TMP_InputField>() == null);
if (GetComponent<TMPro.TMP_InputField>() != null)
{
Debug.Log("True");
return true;
}
else
{
Debug.Log("False");
return false;
}
}
This produces the follow results in the console
True
False
False
Yes, it does not print the “===================> TEST FUNC 1 !!!” portion, just the results, but more importantly, although “GetComponent<TMPro.TMP_InputField>() != null” evaluates correctly to “True” in the debug statement, it evaluates to false in the if statement.
Any idea what is happening?