I recently purchased this plugin and I've been using it mainly for static UI content at the moment. I was trying to use this on a scene where a good portion of the UI is dynamic and updated via scripts. One thing I noticed was that certain objects were not resizing property after being added to a responsive container via code but If I stop running the game and adjust in the editor, it resizes like I would expect. Is there something I need to do different to make this work dynamically and auto adjust?

    I just want to add a comment about this. I saw on the ResponsiveContainer script that there was a "Resize" function that you could pass in a boolean to force UI updates. I added that to my code and It's updating as expected now. Is that the recommended way to handle UI updates when dynamically changing the UI?

      bkennedy Hi! Thanks for your comment, that plugin is fairly new, so it definitely needs suggestions. You're right forcing the update is the best option so far, but the plugin should be able to update itself when adding/removing items, as you can see in some of my demos. I'm suprised it's not working for you, do you have a different need? In what way to you update the UI hierarchy? Thanks

        Thanks for the quick response. Plugin has been great and easy to use thus far. In our code we have UI prefabs that are instantiated from scripts. When I use "FitContentToContainer" on the parent Responsive Container, the child objects adjust accordingly in the editor when i'm testing but when I run in game mode they are not auto adjusting. Now that I call the "Resize" function though it will adjust like it does in the editor.

        My example would be just a simple container (parent) and six child objects in it. When the game loads, all 6 are loaded and visible but there are some scripts that turn off, i'll just say 2 of them, if they are not being used. Once they are turned off, its like the parent object did not recognize the update so the child elements do not expand to fill in the container. That is why I wanted to reach out and make sure I was not doing something wrong.

          bkennedy The container might still take into account the GameObjects deactivated as children to calculate sizes, because there was no change in term of children count, so no Resize() has been triggered. Right now what you can also do is change the parent of the children when you deactivate them. But calling Resize(true) is also a good way to go. Thanks for letting me know I will work on that.

            19 days later

            bkennedy Just so you know I published an update that handles gameobjects activation/deactivation. There is a new demo scene as well for it.

              19 days later

              Sorry for the late reply. I will download the update and test it out and let you know. Does this mean I no longer need to manually call Resize(true)?

                bkennedy Check out the script Demo_ItemDeactivation.cs, you still need to call Resize(true) but the child management and spacing works like a charm now.

                  Just an update to this. I updated the plugin and tested it out. It seems to be auto adjusting for child elements of the Responsive Container as long as the child element does not contain a Responsive Container of its own. To solve this, I had to just write a recursive function that loops through child elements and check if they contain a Responsive Container and then call Resize(true) on them if they do. It would be great on a future update if the root object could detect a change and adjust the hierarchy without having to manually call resize for every element that contains a responsive container.

                    bkennedy that's a good point, thanks I will add that for the next update!

                      Write a Reply...