- Home /
Getting a slider's width to match the size of the group it's in?
I have Vertical Group Layout. Inside are 2 children, a Horizontal Group Layout, and a Slider. In the Horizontal Group Layout I have several icons
+-Vertical Group Layout
+- Horizontal Group Layout
| +- Icon 1
| +- Icon 2
| +- Icon 3
+- Slider
Visually I want it to be something like
+--------+--------+--------+
| | | |
| Icon 1 | Icon 2 | Icon 3 |
| | | |
+--------+--------+--------+
| |
| <===[Slider]===========> |
| |
+--------------------------+
What do I need to do to get the slider's width to match the number of Icons. As I add Icons the Horizontal Group Layout manages them as I'd expect but I haven't been able to figure out how to get the slider to match the size, at least not without code.
Is it possible to make the slider magically size itself in the above case?
Answer by CBV · Mar 21, 2020 at 03:40 PM
Well, not magically, but you can easily do it with some code. Just add to your script some GUILayout:
GUILayout.BeginVertical(GUILayout.Width(200));
GUILayout.BeginHorizontal;
ICon1;
Icon2;
Icon3;
GUILayout.EndHorizontal;
Slider;
GUILayout.EndVertical;
Could be, that inside the code are some typos, please check with intellisense
Your answer
Follow this Question
Related Questions
How can i let the user change some objets' material 0 Answers
How do I properly make assets for mobile games 1 Answer
All interfaces in one Script 1 Answer
UI behavior on resolution change 1 Answer