Poco-SDK
Poco-SDK copied to clipboard
Unity poco Unable to get the text of a text field created using text mesh pro
Unity poco Unable to get the text of a text field created using text mesh pro
Am unable to get the text of these text mesh pro, its showing as nodes in the UI hierarchy. I tried using get_text() and attr('text') as well
Textmesh pro is a third plug-in, You can refer to the GameObjectText
function in UnityNode.cs
to get the attr of TEXT INPUT BOX by yourself.
Hi! I need to be able to read TextMeshPro text too, but i'm having some problems when trying to do this, help would be appreciated.
For my needs, i've modified the GameObjectText function to return TMP_Text if available and the normal Text if not. Here is my code:
private string GameObjectText() { TMP_Text tmpText = gameObject.GetComponent<TMP_Text>(); if (tmpText) return tmpText.text; Text text = gameObject.GetComponent<Text>(); if (text) return text.text; return null; }
With this implementation, when i'm connected to an Android phone, i'm always getting the default value that is setted on the Unity Inspector, but not the actual updated value that i'm seeing ingame. It doesn't matter if it's through Airtest UI-hierarchy view or by poco("MoneyButtonText").get_text() on Python. The normal Text (not TMP text) is updating without problems and sends always the last value.
For some reason, the solution works flawless over UnityEditor.
Is there any way to "update" the value, the dump, or whatever is needed?
Thanks in advance
I've solved it by changing this line if (tmpText) return tmpText.text; to if (tmpText) return tmpText.GetParsedText();