- Home /
Accordion with free style children
I asked my question on this forum but not sure if anyone is watching it so i will try here.
I want to achieve the accordion effect with different sections in a large form. The above linked forum has exactly what i want.. except it does not work for me with free styling children! By this i mean, I was hoping i could add a cell on the grid that would contain a less constrained mix of buttons, labels and input boxes. If i do this, it will not collapse however.
Using the downloadable script, could you tell me how i would add, for example, a button that is 40x40 units large when expanded then disappears to show only the heading when closed?
Thanks in advance to anyone who can help me with this.
Update: Worth mentioning that i originally planned to pin each section to its sibling above. That way if the above sibling is expanded it will push the below sibling down. However this only works with parent-child relationships. I would have a massively deep hierarchy if i put each section inside another section all the way down - not pretty.
Answer by AlwaysSunny · Nov 11, 2014 at 06:29 PM
So these are 4.6 UI elements you're talking about? Every aspect of these elements are script-able to achieve what you're asking for. I made something similar to that video by having buttons (label strips) which cause their child to activate or deactivate. The child contains all the elements as sub-children. Child groups can be dynamically created through prefabs and code, or built in the inspector. If the whole system is built such that each element group and toggle / label strip are children of the same object, and you make liberal use of the Layout elements and their properties, you can mimic what is seen in that video and expand upon it as you describe.
Just spent another hour playing with layout elements and trying to mimic what you are talking about. Am i wrong in my assumption that this can be done without scripting? You mentioned it but i feel the concept is so simple - If there is space above you, don't stretch but ins$$anonymous$$d move your position upwards to fill it. If something above you gets larger due to expanding, move down so the padding between you is still fixed.
Wasted too much time obsessing over this. Bit the bullet and coded it no problem. Just seems like there would have been a 'correct' unity new UI way of doing it.
Your answer
Follow this Question
Related Questions
FPSControl and RPG Starter Kit conflict! 1 Answer
Bar with segments depending on a value. 0 Answers
Problems With NGUI on MAC 1 Answer
NGUI Texture 0 Answers
NGUI Buttons 2 Answers