Resolves issue in 2022 with the missing Text component

Fixes: https://github.com/Unity-UI-Extensions/com.unity.uiextensions/issues/424
pull/413/head
Simon Jackson 2023-02-04 10:30:40 +00:00
parent 7545ab9fde
commit 1002db24f2
1 changed files with 8 additions and 0 deletions

View File

@ -8,7 +8,11 @@ namespace UnityEngine.UI.Extensions
{ {
public RectTransform rectTransform; public RectTransform rectTransform;
public Button btn; public Button btn;
#if UNITY_2022_1_OR_NEWER
public TMPro.TMP_Text txt;
#else
public Text txt; public Text txt;
#endif
public Image btnImg; public Image btnImg;
public Image img; public Image img;
public GameObject gameobject; public GameObject gameobject;
@ -19,7 +23,11 @@ namespace UnityEngine.UI.Extensions
rectTransform = btnObj.GetComponent<RectTransform>(); rectTransform = btnObj.GetComponent<RectTransform>();
btnImg = btnObj.GetComponent<Image>(); btnImg = btnObj.GetComponent<Image>();
btn = btnObj.GetComponent<Button>(); btn = btnObj.GetComponent<Button>();
#if UNITY_2022_1_OR_NEWER
txt = rectTransform.Find("Text").GetComponent<TMPro.TMP_Text>();
#else
txt = rectTransform.Find("Text").GetComponent<Text>(); txt = rectTransform.Find("Text").GetComponent<Text>();
#endif
img = rectTransform.Find("Image").GetComponent<Image>(); img = rectTransform.Find("Image").GetComponent<Image>();
} }
} }