Search Unity

Chat system like a chat app scrolling issue

Discussion in 'UGUI & TextMesh Pro' started by Corva-Nocta, Nov 3, 2022.

  1. Corva-Nocta

    Corva-Nocta

    Joined:
    Feb 7, 2013
    Posts:
    801
    Hey all! I'm looking to make a chat system in my game that resembles texting on a phone. I've got nearly everything figured out for making it work, only problem I am hitting is how to make it scroll properly. I can't seem to get the settings right to make it work and I'm wondering if anyone knows what is wrong.

    I've got my ScrollView object, and text objects will appear in the content. So far this works just fine! I also have a vertical layout group in the content so all the texts appear and push the previous ones. So far so good. The trouble I am having is that if I set the vertical layout group to start from the bottom, the texts get pushed properly until the content gets filled on the screen, then it just locks. But if I set the vertical layout group to start at the top, it pushes texts down infinitely. How do I reverse this? I think I've tried every setting!

    I need it to set the most recent text object in the vertical layout to the bottom most area, but then extend infinitely up. I seem to only be able to do the opposite. Any ideas? Am I missing something incredibly small?
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,456
    Given how long you've had an account, I'm quite surprised you don't know that there are several dedicated forums for UI. The 2D forum and featureset are not related to UI.

    Anyway, I'll move your post to the UGUI forum. Hopefully you can then get the help you need there.
     
    Corva-Nocta likes this.
  3. Corva-Nocta

    Corva-Nocta

    Joined:
    Feb 7, 2013
    Posts:
    801
    Appreciate the move! I've not really done a lot of work with UI, other than the simple stuff like buttons. Never really needed help on it before haha. But this one is giving me some trouble.
     
    MelvMay likes this.
  4. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,913
    Try a ContentSizeFitter with vertical preferred on the same object as the VerticalLayoutGroup. In ScrollView, this should be set as your Content in the inspector.
     
  5. Corva-Nocta

    Corva-Nocta

    Joined:
    Feb 7, 2013
    Posts:
    801
    I did try that, but the text objects add infinitely down and don't push all the content up. So the text objects appear like they should (newest one at the bottom) but once the screen is filled it just keeps adding text objects to the bottom but off screen. Once the screen is full it won't push everything up anymore, so you can't ever see the most recent text objects.
     
  6. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,411
  7. Corva-Nocta

    Corva-Nocta

    Joined:
    Feb 7, 2013
    Posts:
    801
    That looks like a good one! But I don't think it does scrolling up, all the examples in the video have infinite scrolling down, which is what I already have. But maybe I will look around for an asset or something, that might be a better answer for me.
     
  8. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,913
    Corva-Nocta likes this.