Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Yeah, I think the problem may be that it's two content size fitters immediately inside of one another (but I'd expect this to effect size, not position... so might be the wrong path to look down?) ...without a layout group or layoutelement to help decide what controls what.


The way the code I sent works is... you reference an STM component, then you reference a LayoutElement component, and the height value from STM is sent directly to the layoutElement's "preferredHeight" field. (Make sure preferred height is enabled on the layoutelement or this does nothing) The LayoutElement is intended to be the parent object of the one STM is on, in this example. I'm catching this before bed, could add the other fields besides height for you tomorrow.


Hm, you said before that TextBoxContainer also has a vertical layout group already, but it *might* work here with using a layoutelement and setting values directly from the child STM object. I'm still not completely convinced this is the error though since it's *always* just returning to the same point before being corrected what I can assume is a layout refresh... so even if we fix the layout refresh, something could still be responsible for the move.

It might also be worth seeing if reducing nesting would help - could txtSubtitles be made a sibling of Panel_TextBG instead of a child? If you go into STM's sample scenes, there's a "MatchRect" script that will let one rectTransform fit to STM with various settings, regardless of parenting. I forgot to mention this before, this is probably a more direct and thorough fix than piggybacking off LayoutElement... probably!


So please give that last one a shot! That might be better since you're trying to size a box based on text size, anyway!

(1 edit)

Hey, thanks so much for these suggestions.
After a lot of fiddling, it seems like the conflict is maybe the nesting, or rather having 2 'Vertical Layout Group' components on 2 different nested objects. If I disable one of the Vertical Layout Groups, I don't get the issue. I tried replacing one with a Horizontal Layout Group, but no luck.

I did try a Layout Element - it gets rid of the recording position glitch, but I couldn't seem to get the wrapping of the text right (the text ran off the screen), or the background box just didn't shrink to conform to the text - this kind of double nested setup I have seems to be the only way I can find thus far to get the text to wrap correctly to a max shape. 

I also tried your script, and just couldn't figure out how to get it to work with the Adventure Creator Subtitles menu I'm afraid -  maybe the ACWiki script was clashing with it, not quite sure. If you have more suggestions for how to set that up correctly, I'd love to please try! 🙏