Autosize input field (horizontally) to it's contents?

I have my UI as follows
5834161--618868--upload_2020-5-11_20-11-27.png
Its a horizontal layout such that it auto sizes based on the text.
This works great, but I want to make it such that a user can edit the text, and hence it needs to be an input field. I can’t work out any combination of layout components and content size fitters that does the job properly? Adding a layout to the input field works but

  • There is extra undesired padding
  • The caret and highlighting show up in the completely wrong place

On Unity 2018.3 with TMP 1.4.1, can upgrade to 2018.4 but not further

Thanks!

Since I made some improvements to the TMP Input Field in terms of its support for Layout Components in the latest releases of the TMP package, I suggest you give a try to the latest release which is version 1.5.0-preview.12 for Unity 2018.4.

Let me know the outcome.

1.5.0.preview.12 + ContentSizeFitter on the input field (despite the warning) works perfectly!

Any possible way to get this working in a non preview version? I don’t think I can require my customers to use a preview package

Edit: When typing whitespace there is some weird behaviour where the text goes out of the viewport

This is likely to be the last Preview before going Verified. Preview here is more like a Beta as opposed to Preview like Experimental / not even Alpha. Still beta but not the later.

It is important to respect the warnings as this easily leads to the Layout System getting confused. Normally, if you have a Layout Component on the parents you should not have to use a Content Size Fitter on the TMP Input Field. I believe I have a few posts showing some potential setup for this but I have to look for then on the forum here. A search of recents posts about ContentSizeFitter and TMP Input Field should reveal something.

I’ll look for some example tomorrow and post it if you have not found a solution yet.

Awesome, sounds good

Without the content size fitter it wouldn’t expand as necessary, I’ll play around with it some more when I have time and get back to you

Thanks for the help!

I searched around but couldn’t find anything