示例#1
0
 private void Awake()
 {
     dropdownElement = GetComponentInChildren <DropdownElement>();
     dropdownElement.OnValueChanged.AddListener(delegate { CallEventOnValueChanged(dropdownElement.selectedValue); });
 }
示例#2
0
	public void AddElement(int _index, string _title)
	{
		RectTransform _ref = Instantiate(elementPrefab) as RectTransform;
		_ref.SetParent (gfx.transform);
		_ref.localScale = Vector3.one;
		Transform _titleObj = _ref.FindChild("Title");
		if (_titleObj == null)
		{
			Debug.LogError("No object called 'Title' found under the element prefab");
			return;
		}
		Text _titleText = _titleObj.GetComponent<Text>();
		if (_titleText == null)
		{
			Debug.LogError("No Text component on the title object");
			return;
		}
		_titleText.text = _title;
		Transform _indexObj = _ref.FindChild("Index");
		if (_indexObj == null)
		{
			Debug.LogError("No object called 'Index' found under the element prefab");
			return;
		}
		Text _indexText = _indexObj.GetComponent<Text>();
		if (_indexText == null)
		{
			Debug.LogError("No Text component on the index object");
			return;
		}
		_indexText.text = (_index + 1).ToString("D2");
		DropdownElement _element = new DropdownElement(_index, _title, _ref);
		elements.Add(_element);
	}