///Credit ChoMPHi ///Sourced from - http://forum.unity3d.com/threads/accordion-type-layout.271818/ namespace UnityEngine.UI.Extensions { [RequireComponent(typeof(HorizontalOrVerticalLayoutGroup), typeof(ContentSizeFitter), typeof(ToggleGroup))] [AddComponentMenu("UI/Extensions/Accordion/Accordion Group")] public class Accordion : MonoBehaviour { private bool m_expandVertical = true; [HideInInspector] public bool ExpandVerticval => m_expandVertical; public enum Transition { Instant, Tween } [SerializeField] private Transition m_Transition = Transition.Instant; [SerializeField] private float m_TransitionDuration = 0.3f; /// /// Gets or sets the transition. /// /// The transition. public Transition transition { get { return this.m_Transition; } set { this.m_Transition = value; } } /// /// Gets or sets the duration of the transition. /// /// The duration of the transition. public float transitionDuration { get { return this.m_TransitionDuration; } set { this.m_TransitionDuration = value; } } private void Awake() { m_expandVertical = GetComponent() ? false : true; var group = GetComponent(); } #if UNITY_EDITOR private void OnValidate() { if (!GetComponent() && !GetComponent()) { Debug.LogError("Accordion requires either a Horizontal or Vertical Layout group to place children"); } } #endif } }