Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Unity UI Setting Vertical Layout Group Alignment/Padding per child?

Discussion in 'UGUI & TextMesh Pro' started by cavegift, Apr 27, 2020.

  1. cavegift

    cavegift

    Joined:
    Sep 4, 2019
    Posts:
    1
    Hi! I'm building a very rough texting-app style UI for a small project, and I have a system in place for instantiating and placing dialogue text objects within a scrollable screen. My main issue at the moment is figuring out how to align them in a way that matches most popular texting apps-- with sent texts aligning to and growing from the right side, received texts from the left side, and system messages from the middle.

    Here's a picture of my layout for my UI at the moment:

    The "Scroll area" is a simple Scroll Rect with a Mask that scrolls the "Messages Zone," the parent for the texts that I instantiate. Messages Zone has a Vertical Layout Group component that handles the spacing, padding and alignment for individual texts spawned into it, which controls how far messages are apart as well as throttles their maximum width before the text inside wraps to another line. It also uses a Content Size Fitter to grow in height as more objects are added inside it. I'd like to find a way to set both the alignment and the padding on these spawned "received text" objects on the fly depending on their purpose. Is there a script or component I could use to accomplish this? Or will I have to use a different approach entirely? Let me know if there's any more info I can provide.
     
  2. gsutton111

    gsutton111

    Joined:
    Oct 15, 2020
    Posts:
    1
    Hi! Did you manage to figure something out for this? I've been looking for a similar thing and can't seem to figure it out :(