Dear Chris and AC followers,
I wish you a very happy 2021!
So, I'm still in the polishing phase of ENCODYA and I've a little glitch I'd like to solve.
Basically my Menu buttons size is not changing right after I change language. I've to exit the menu and re-enter it again to make it work.
I'm using Unity UI Prefabs. To change language I use standard AC Language Cycle in a Menu called "Options" which also pause the game. The buttons in the menu are UI buttons with a Content Size fitter, to re-adapt themselves according with the text size. They all work well (i.e. the button "area" adapt to the text length) but only the second time I visit a menu after changing language (i.e. if I switch language the buttons keep the size of the previous language, I've to exit and re-enter the menu to make it work).
How can I refresh my buttons size (and overall all the AC Menus) on clicking the language cycle in my options?
P.S. I'm using the Dynamic Font Language so I thought to add some lines in the "OnChangeLanguage" event, but I'm not sure what...
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
If you're using Unity UI, then its down to Unity's own UI components (such as Content Size Fitter) to resize elements based on their contents - AC is not involved in this process.
There are a few threads on the Unity forums regarding this issue, each with suggestions:
https://forum.unity.com/threads/content-size-fitter-refresh-problem.498536/
https://answers.unity.com/questions/1276433/get-layoutgroup-and-contentsizefitter-to-update-th.html
https://forum.unity.com/threads/force-immediate-layout-update.372630/
See in particular Sun-Pengfei's reply in the latter thread, which suggests that this can be solved not through code but by careful arrangement of such components in your UI's hierarchy.
Thanks, will give a try!