- Home /
Question/suggestion about layout system
Hi!
In new UI system you can't do the following: "Place number of buttons via scripts to some area. Resize window. Probably your buttons will not be resized or they could be resized but in the way you do not want. For example, I want my buttons to be square form no matter how the window is scaled. But I want them to be scaled if the window size changed."
I can do that.. But with many tricky hacks.. I could use layout system (that is practically not mentioned in documentation) and try to change preferred width and/or height of UI elements. However I should determine whether the window size was changed or not(that is a hack too).
So my question is how to do that ? May be I missed something ? And my suggestion is: Add some element to layout system that allows to do what I described above.
Thanks in advance.
Answer by Slev · Sep 22, 2014 at 01:10 PM
Have you tried using the Reference Resolution component? That resizes while maintaining object aspect ratios.
Hi!
Now I tried this component, but I do not know how to use it. Documentation is unfortunately too poor for layout components. I tried, however, another hack, but confronted with another problems. So I tried several layout structures. The most common structure that shows some results is:
ScrollView(ScrollRect+Image+$$anonymous$$ask+$$anonymous$$yScript)
Content(Horizontal layout + ContentSize Filter)
--- Item(Image + Button + LayoutElement)
So $$anonymous$$yScript that is on top deter$$anonymous$$es if the window size was changed and if it was set the new size to the Items that is on the bottom in the structure above. However the relative position item with the Content(holder) changes and there is a need for recalculation of it.
I'll show you it in the example: Before:
After changing window size:
So the size of the items is changing, but the position is not.
I do not know how to fix it for now.
Answer by QuindoDark · Sep 22, 2014 at 02:19 PM
What you are going to want to do is use a grid layout and a WindowClass script. Whenever the Window is resized have a function in WindowClass check the new width and height of the window and determine what the new Cell Height and Width should be. If the Grid Layout fails to update a quick enable and disable of it should fix it.
Your answer
Follow this Question
Related Questions
Tech tree element positioning 0 Answers
Spawn objects (Instantiate) behind hierarchy 1 Answer
UI Button Trigger? 1 Answer