This is based on ChoMPi 's work.
You can check more information on this topic
Just download the project and see the demo scene.
- demo
- AddListener
Adding a listener to this script is similar to UGUI's Button.
public class yourUIClass:MonoBehaviour
{
private UIAccordion m_UIAccordion;
private void Awake()
{
m_UIAccordion = GetComponent<UIAccordion>();
m_UIAccordion.onSelectElement.AddListener(OnElementSelect);
}
private void OnDestroy()
{
m_UIAccordion.onSelectElement.RemoveListener(OnElementSelect);
}
private void OnElementSelect(int index)
{
Debug.Log("New Element Index:" + index);
}
}