Home > Back-end >  How to get the Placeholder of a TMPro.TMP_InputField in Unity?
How to get the Placeholder of a TMPro.TMP_InputField in Unity?

Time:08-30

I have TMPro.TMP_InputField, but I am confused how to get the Placeholder of that.

enter image description here

.Placeholder is null, so that doesn't point to anything.

Also it seems like Placeholder is a subcomponent of an empty game object called Text Area?

And from what I see there is no .GetComponents() that returns all sub-components, unless you know the type (and I don't know what type Text Area is).

enter image description here

So, I am unsure how to effectively get the Placeholder component so that I can manipulate it.

Any advice would be appreciated!

CodePudding user response:

I managed to target it with:

inputfield.transform.Find("Text Area").Find("Placeholder").GetComponent<TMPro.TMP_Text>();

  • Related