///Credit perchik ///Sourced from - http://forum.unity3d.com/threads/receive-onclick-event-and-pass-it-on-to-lower-ui-elements.293642/ using UnityEngine; using UnityEngine.UI; using System.Collections; using System.Collections.Generic; using System.Linq; using System.ComponentModel; [RequireComponent(typeof(RectTransform))] public class ComboBox : MonoBehaviour { #region declarations #region private members private bool _isActive = false; //is the drop down panel active private Button comboBtn; private Image comboBtnImg; private Text comboBtnText; private Button overlayBtn; private GridLayoutGroup itemLayout; private float _scrollbarWidth = 20.0f; private int scrollOffset; //offset of the selected item private int _itemsToDisplay = 4; //how many items to show in the dropdown panel private bool _hideFirstItem = false; //lets us hide the prompt after something is chosen private int _selectedIndex = 0; private List _items; //conceptual items in the list private bool _interactable = true; #region private rect transforms /// All of these have to be properties so that the editor script can access them private RectTransform _overlay; //overlayRT is a screensized box to handle clicks *not* on the button. (although this might have to change with multiple things on the screen. private RectTransform overlayRT { get { if (_overlay == null) { _overlay = rectTransform.FindChild("Overlay").GetComponent(); overlayBtn = _overlay.gameObject.GetComponent