Home > Software design >  TextMeshPro Input field - can't set placeholders' wrapping to enabled?
TextMeshPro Input field - can't set placeholders' wrapping to enabled?

Time:11-26

I am trying to have a TMP Input Field with multiline (wrapped) placeholder. The input field has its content type set to Integer Number. Placeholder text has some string as text and has wrapping set to "enabled". In prefab editor, it looks ok (text is wrapped). However, when the scene loads, placeholder text immediately has its wrapping reset to "disabled".

The problem: I assume Input field resets the wrapping to disabled on child text, because its content is not multiline, as specified screenshot

Right now it works as I expect. However, now I want to dynamically change the placeholder text, so I don't know where the newline will be and I would like for TMP to wrap the text for me, same as it does in Text component with Wrapping enabled.

So: how do I use TMP's wrapping - enabled on InputField without it getting reset to disabled? Either both the user input and placeholder, or just on placeholder itself - doesn't matter.

CodePudding user response:

MultiLine is only available if the Content Type is set to Standard or Auto Corrected.

As soon as you set the input type to Integer Number it basically behaves just like an integer field in the Unity Inspector: No line wrapping but rather overfloating and scrolling to the right.

Alternatively if you need multi lines you could set the Content Type to Custom and then fully flexible adjust it to your needs like e.g.

  • LineType : Multi Line Newline
  • Line Limit: 0
  • Input Type: Standard
  • Keyboard Type: Default
  • Character Validation: Integer

And in general: Of course you also can't set a text to an input field that only accepts integer numbers ;) Rather set your placeholder text in the Placeholder object!

Anything that is applied to the Placeholder will be displayed automatically as long as there is no value typed in the input field!

  • Related