Search Unity

Content Size Fitter in ScrollView

Discussion in 'Unity UI (uGUI) & TextMesh Pro' started by elpuerco63, Jan 15, 2018.

  1. elpuerco63

    elpuerco63

    Joined:
    Jun 26, 2014
    Posts:
    271
    I'm trying to get a single text game object to auto size dynamically at runtime and have the scroll view adjust to suit as the text length grows.

    I've finally managed it via the use of a content size fitter with the vertical fit set to preferred size and the text vertical overflow to to overflow.

    This works and the text field grows as expected but what is happening is the scroll view is scrolled part way down rather remaining at the top?

    Normally I reset the scroll view content to top like this:

    Code (csharp):
    1.  
    2. textAnchoredPosition = textContent.GetComponent<RectTransform> ().anchoredPosition;
    3.  
    But this does not seem to work when used with a content size fitter component present?
     
  2. elpuerco63

    elpuerco63

    Joined:
    Jun 26, 2014
    Posts:
    271
    Found it :)



    Specifically from 2:58 :)
     
unityunity