I am trying to make a GUI using the new 4.6 GUI components. This screen needs to be able to expand and contract depending on the values that the user enters.
For example if the user checks a certain checkbox, several more input fields need to show up. If they uncheck that box, those input fields need to be hidden.
I am trying to do it with the auto layout components, but can’t get it to work.
After reading your topic i had this urge to see if accordion effect could be achieved with the gui layout elements so i decided to give it a shot and here are my results.
Also i am attaching the project from the video to this post, you guys feel free to use, share or do whatever you feel like with it : ]
I love this community. Thank you. I will have to modify a little bit because I need to have multiple sections open at the same time. Maybe that is called a collapsible and not an accordion.
I used the collapsible version along with knowledge from this tutorial on layouts to try solve the same issue as you had but i am still having difficulty. I was hoping i could add a cell on the gird that would contain a less constrained mix of buttons, labels and input boxes. This box will not collapse however.
Using the downloadable example, 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.
If you have a child of an AccordianElement, such as an image, which then has a child, such as some text, when its collapsed the text is still shown. Any way to fix this?
I seem to be having trouble getting it to work then.
I want a persistent label present like the heading in the demo video, but with nested buttons that are shown when the accordion is on. I can’t seem to get the child elements to hide when the accordion is turned off.
EDIT: Used the collapsible one linked above instead. Its working great! I hope it works well inside a dynamically sized scroll pane.
Hi Chompi. the Collapsible version Works fine. But the transition happens in both directions. anyway to make sure that when it expands, it is downward.
Maybe this is a bit late for you, but if you want it to expand downward, set your Y Pivot on the rect transform containing the Accordion to 1 instead of 0.5.
Hi, this is a amazing project. But I’m having some problens to build the project. I recived the following message:
Assets/Accordion/Scripts/UIAccordionElement.cs(40,41): error CS0115: `UnityEngine.UI.UIAccordionElement.OnValidate()’ is marked as an override but no suitable method found to override
When I have a button as the top element, instead of a simple text, the event is beeing caught by that button. So the accorion won’t open. I need that button to define the gameobject im working on. Is there a simple solution to that ?
Using Unity 5.3.2f, when I try and compile I get:
error CS0115: `UnityEngine.UI.UIAccordionElement.OnValidate()’ is marked as an override but no suitable method found to override
I may just be an idiot but I cannot get this to work. Anything particular I need to know about the heirarchy or any specific settings. I have an Accordion Group with an Accordion Element child. How does the setup need to be under accordion Element?