///Credit perchik ///Sourced from - http://forum.unity3d.com/threads/receive-onclick-event-and-pass-it-on-to-lower-ui-elements.293642/ using System; using UnityEngine.Events; namespace UnityEngine.UI.Extensions { [Serializable] public class DropDownListItem { [SerializeField] private string _caption; /// /// Caption of the Item /// public string Caption { get { return _caption; } set { _caption = value; if (OnUpdate != null) OnUpdate(); } } [SerializeField] private Sprite _image; /// /// Image component of the Item /// public Sprite Image { get { return _image; } set { _image = value; if (OnUpdate != null) OnUpdate(); } } [SerializeField] private bool _isDisabled; /// /// Is the Item currently enabled? /// public bool IsDisabled { get { return _isDisabled; } set { _isDisabled = value; if (OnUpdate != null) OnUpdate(); } } [SerializeField] private string _id; /// ///ID exists so that an item can have a caption and a value like in traditional windows forms. IE. an item may be a student's name, and the ID can be the student's ID number /// public string ID { get { return _id; } set { _id = value; } } public UnityAction OnSelect = null; //action to be called when this item is selected internal UnityAction OnUpdate = null; //action to be called when something changes. /// /// Constructor for Drop Down List panelItems /// /// Caption for the item /// ID of the item /// /// Should the item start disabled /// UnityAction to be called when this item is selected public DropDownListItem(string caption = "", string inId = "", Sprite image = null, bool disabled = false, UnityAction onSelect = null) { _caption = caption; _image = image; _id = inId; _isDisabled = disabled; OnSelect = onSelect; } } }