Search Unity

Unity UI Content Size Fitter Troubles

Discussion in 'UGUI & TextMesh Pro' started by MoonJellyGames, Jul 7, 2022.

  1. MoonJellyGames

    MoonJellyGames

    Joined:
    Oct 2, 2014
    Posts:
    331
    Hi all,

    UI stuff has always been particularly difficult for me, so please bare with me.

    I have a few TextMeshPro UI objects in a vertical layout group that display information about each ship's properties, and each of their weapons. Miraculously, this is working almost exactly as I intended. The only lingering problem is that I can't get the content size fitter to behave as I'd expect while cooperating with the scrollbar.

    I've made the content size for each weapon description larger than it needs to be. The scrollbar works as expected here. But if there is only a small amount of text, I don't want to be able to scroll into nothing. In fact, the scrollbar should hide altogether (I do have them set to autohide and expand).

    As I started typing this up, I look one more look at my project and discovered the "ScrollRect" overflow option for TextMeshPro. I felt stupid for not realizing this option was present, only to find that it doesn't seem to work. If this thread is any indication, the feature is just broken. I'm assuming that there are workarounds, but none of the ones I've come across have been successful. Any ideas?

     
  2. karliss_coldwild

    karliss_coldwild

    Joined:
    Oct 1, 2020
    Posts:
    602
    Here is a setup that works for me:

    * content -> vertical layout (control child size width+height, child force expand width), content size fitter (vertical fit preferred)
    ** text mesh pro, no additional components
     
    MoonJellyGames likes this.
  3. MoonJellyGames

    MoonJellyGames

    Joined:
    Oct 2, 2014
    Posts:
    331
    Oh my gosh, this actually worked exactly as I wanted. Thank you so much!