Layout/size for inline, async-loaded textures
Posted: 26 Nov 2024, 19:30
Hi, I'm having trouble getting images to work inline with text when that image has to be loaded asynchronously in Unity. I can reproduce the problem with a text block like this:
...where `Image` binds to a `UnityEngine.Texture` that's not immediately provided.
The result is the two text elements next to each other; the GUI inspector resource adorner shows the image outside the visible area of the text: If the text has a hover style change (e.g. changing `TextBlock.Foreground` to a new brush), the image takes up space, but the overall layout doesn't react to the space taken up (and the suffix text is cut off, in a way it wouldn't be if I put in a much longer message with no images). My overall goal is to support controller input hints in localized text; my implementation is built alongside Noesis' RichText bbcode tags, which is why I'm dealing with images and inline text blocks - and threading constraints mean I need to supply the image asynchronously. Is there something I could do differently to get the size/layout to propagate right?
Code: Select all
<TextBlock>
<Run>Prefix Text</Run>
<InlineUIContainer>
<Image Source="{Binding Image}" />
</InlineUIContainer>
<Run>Suffix Text</Run>
</TextBlock>
The result is the two text elements next to each other; the GUI inspector resource adorner shows the image outside the visible area of the text: If the text has a hover style change (e.g. changing `TextBlock.Foreground` to a new brush), the image takes up space, but the overall layout doesn't react to the space taken up (and the suffix text is cut off, in a way it wouldn't be if I put in a much longer message with no images). My overall goal is to support controller input hints in localized text; my implementation is built alongside Noesis' RichText bbcode tags, which is why I'm dealing with images and inline text blocks - and threading constraints mean I need to supply the image asynchronously. Is there something I could do differently to get the size/layout to propagate right?