Updated UIVertical scroller to be 2022 compliant

Resolves:
- https://github.com/Unity-UI-Extensions/com.unity.uiextensions/issues/410
pull/413/head
Simon Jackson 2022-11-27 14:32:16 +00:00
parent 8004bcf39b
commit c5a8af63f8
2 changed files with 16 additions and 2 deletions

View File

@ -191,7 +191,19 @@ namespace UnityEngine.UI.Extensions
if (minDistance == distance[i])
{
focusedElementIndex = i;
result = _arrayOfElements[i].GetComponentInChildren<Text>().text;
#if UNITY_2022_1_OR_NEWER
var textComponentTxtMeshPro = _arrayOfElements[i].GetComponentInChildren<TMPro.TMP_Text>();
if (textComponentTxtMeshPro != null)
{
result = textComponentTxtMeshPro.text;
}
#else
var textComponent = _arrayOfElements[i].GetComponentInChildren<Text>();
if (textComponent != null)
{
result = textComponent.text;
}
#endif
}
}
if (focusedElementIndex != oldFocusedElement && OnFocusChanged != null)

View File

@ -1,8 +1,10 @@
{
"name": "UnityUIExtensions",
"rootNamespace": "",
"references": [
"GUID:2bafac87e7f4b9b418d9448d219b01ab",
"GUID:75469ad4d38634e559750d17036d5f7c"
"GUID:75469ad4d38634e559750d17036d5f7c",
"GUID:6055be8ebefd69e48b49212b09b47b2f"
],
"includePlatforms": [],
"excludePlatforms": [],