2015-02-10 08:03:38 +08:00
|
|
|
|
///Credit perchik
|
|
|
|
|
///Sourced from - http://forum.unity3d.com/threads/receive-onclick-event-and-pass-it-on-to-lower-ui-elements.293642/
|
|
|
|
|
|
|
|
|
|
namespace UnityEngine.UI.Extensions
|
|
|
|
|
{
|
|
|
|
|
[RequireComponent(typeof(RectTransform), typeof(Button))]
|
|
|
|
|
public class DropDownListButton
|
|
|
|
|
{
|
|
|
|
|
public RectTransform rectTransform;
|
|
|
|
|
public Button btn;
|
2023-02-04 18:30:40 +08:00
|
|
|
|
#if UNITY_2022_1_OR_NEWER
|
|
|
|
|
public TMPro.TMP_Text txt;
|
|
|
|
|
#else
|
2015-02-10 08:03:38 +08:00
|
|
|
|
public Text txt;
|
2023-02-04 18:30:40 +08:00
|
|
|
|
#endif
|
2015-02-10 08:03:38 +08:00
|
|
|
|
public Image btnImg;
|
|
|
|
|
public Image img;
|
|
|
|
|
public GameObject gameobject;
|
|
|
|
|
|
|
|
|
|
public DropDownListButton(GameObject btnObj)
|
|
|
|
|
{
|
|
|
|
|
gameobject = btnObj;
|
|
|
|
|
rectTransform = btnObj.GetComponent<RectTransform>();
|
|
|
|
|
btnImg = btnObj.GetComponent<Image>();
|
|
|
|
|
btn = btnObj.GetComponent<Button>();
|
2023-02-04 18:30:40 +08:00
|
|
|
|
#if UNITY_2022_1_OR_NEWER
|
|
|
|
|
txt = rectTransform.Find("Text").GetComponent<TMPro.TMP_Text>();
|
|
|
|
|
#else
|
2017-06-04 00:59:12 +08:00
|
|
|
|
txt = rectTransform.Find("Text").GetComponent<Text>();
|
2023-02-04 18:30:40 +08:00
|
|
|
|
#endif
|
2017-06-04 00:59:12 +08:00
|
|
|
|
img = rectTransform.Find("Image").GetComponent<Image>();
|
2015-02-10 08:03:38 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|