I'm trying to create dialog balloons and finding that the sizes don't update after I change the text in them. Is there a way to get a control to calculate it's size after making changes that will affect the sizes of its children?
You'd better set the label size before update the text.
Comras I don't know what size to set before the text is laid out. If the text is short, I want the dialog to shrink to fit it. Or if after splitting into multiple lines the text is less than the wrap width, I want the box to shrink to that size. So somehow I need to know the ultimate bounding box size of the text so I can set the size of the RichTextLabel.
Embus It will require a bit of logic to get it working the way that I think you are aiming for. Couple things to consider as you approach writing this...
You can use the visible_characters
and/or visible_ratio
properties on the label to spell out the text over time. Use this as the base of the logic to update the size of the bubble. You will want to sort out the custom_minimum_size
before hand and store a maximum_width
and `maximum_height variable in the script.
Once you have those basic building blocks you can write the rest of the logic and throw in some tweens for smooth resizing.
Drop your script here once you have something. I would be happy to continue helping.
© 2022 - 2024 — McMap. All rights reserved.