Forum rules - please read before posting.

Hotspot label size not updating correctly

edited July 2020 in Technical Q&A

My hotspot label is not updating its size correctly. It seems to be consistently stuck on the size of the text content of the last hotspot, and then updating the label size if I point at the same hotspot again. See this video:
https://www.loom.com/share/17bee5e3a1f043cfa9dd2643f82ec9ee

I'm using Unity UI for the label.

Here are screenshots of my elements:
https://imgur.com/RwGmrlj
https://imgur.com/kfr0oI0

As a child of my canvas I have a game object with a Horizontal Layout Group, Content Size Fitter, and Image on it.
This is the actual label. The Image component is to color the label transparent black, and the two other components is to adjust the size to the size of the text content.

And as a child of this element I have another element with a Text component. This is the actual hotspot text. This element also has a Content Size Fitter on it, to make its Rect Transform the size of the actual text content.

I'm not sure if I'm using the Unity UI elements and/or components correctly, and whether the problem is with this or with AC.

My own guess would be that the UI elements are being resized before AC puts the text content into the label, which would be why the label only gets the right size when I point at the hotspot twice. But I don't know how to fix this.

Comments

  • Unity UI's auto-sizing components should update every frame - this is likely less to do with AC and more to do with the way your components are set up.

    See the warning message you're getting on the Text object - the Horizontal Layout Group on the parent is overriding the Content Size Fitter on the child. I'd say the latter would need removing.

  • Thanks for the reply!

    I am aware of the warning, but if I remove the Content Size Fitter from the element containing the text component, it will just keep whatever size I explicitly set on the Rect Transform.

    Anyway, I'm not totally sure how the Unity UI stuff works. If anyone has an idea how to fix it, I'm all ears.

  • I'd expect you can find some relevant threads on the Unity UI threads - it's a general Unity UI issue.

  • Okay, I managed to fix it now. For anyone who might be having the same issue in the future: I removed the Content Size Fitter from the element containing the text component, then I unticked both "width" and "height" for "child force expand" on the parent element (the one containing the Image component), and ticked both "width" and "height" for "control child size".

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.