Search Unity

TextMesh Pro Multiline input field with scrollbar scrolls all the way up on first scroll

Discussion in 'UGUI & TextMesh Pro' started by Toncent, Sep 8, 2017.

  1. Toncent

    Toncent

    Joined:
    Sep 8, 2017
    Posts:
    3
    Hi,
    Here is the behavior i am seeing on Unity 5.6.1f1:
    I have an empty TMP input field set to "multiline new line" that has an attached scrollbar.
    I type in enough text for it to become scrollable (e.g. a bunch of newlines) and then use the mousewheel to scroll.
    The text and scrollbar will then jump all the way back to the top instead of scrolling from the current position.
    After that it behaves as expected scrolling up and down.

    Hope there is an easy fix for it. I can provide a simple scene that has this behavior for me if needed :)
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    A simple repro would be most useful. Also make sure you are using the latest release of TMP which is 1.0.55.56.0b12 in the case of Unity 5.6.

    - Update -
    I was able to reproduce the behavior you have reported and believe I have a solution for it. This will need further testing but I'll provide an update as soon as possible.

    P.S. I presume you are using the free version of TMP right?
     
    Last edited: Sep 8, 2017
  3. Toncent

    Toncent

    Joined:
    Sep 8, 2017
    Posts:
    3
    Oh yes i forgot to say i use the free version. I assume it's the latest version since i just downloaded it from the asset store yesterday. Thanks for looking into it!
     
  4. Trindenberg

    Trindenberg

    Joined:
    Dec 3, 2017
    Posts:
    398
    I take it this problem hasn't been fixed. I am using the Unity TMP InputField with ScrollBar, and when I append the text via code, it scrolls to the top. Where is the 'current scroll position' stored?
     
  5. emorling

    emorling

    Joined:
    Jul 6, 2015
    Posts:
    24
    Any updates on this? I see the same errors with text added upwards rather than down.
     
  6. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I did make improvements in the latest versions of TMP which are 1.4.1-preview.1 for Unity 2018.3 and 2.0.1-preview.1 for Unity 2019.1. Note 1.4.1 and 2.0.1 will be available this week and are the same as those previews.

    I still have additional improvements coming in subsequent releases. Please be sure to re-test the above and report your findings / other potential issues.
     
  7. ThisIsDangerous

    ThisIsDangerous

    Joined:
    Dec 3, 2018
    Posts:
    39
    Hey. I'm just doing
    Code (CSharp):
    1.  
    2. var textComponent = textField.textComponent;
    3. var textViewport = textField.textViewport;
    4. textComponent.rectTransform.anchoredPosition = new Vector2(textComponent.rectTransform.anchoredPosition.x, (textComponent.preferredHeight - textViewport.rect.height) * 1);
    5.  
    to scroll it to the bottom. Replace '1' with any relative number if needed. It is how it is done in TMP_InputField itself as a behavior on scrollbar scroll.
     
  8. Skeldal

    Skeldal

    Joined:
    Apr 30, 2019
    Posts:
    12
    This is probably still best solution.
     
  9. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Additional improvements to the scrollbar behavior were introduced in the latest TMP releases so please be sure to check against those.
     
  10. BrokeTrigger

    BrokeTrigger

    Joined:
    Sep 8, 2020
    Posts:
    1
    This is still an issue- I'm using TMP 3.0.1 on Unity 2020 1.4f1. When you manually enter text in the expanding TMP input box with scroll bar, it works as expected- The scroll bar size increases as more text is entered. The problem is if you exit the field and left click>drag the scroll bar to move the displayed input up\down, as soon as you release the mouse button, the scroll bar will immediately snap to the top.
     
  11. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Please use / re-test using the latest release of the TMP package which is version 3.0.4 for Unity 2020 or newer.