Poco-SDK icon indicating copy to clipboard operation
Poco-SDK copied to clipboard

Unity poco Unable to get the text of a text field created using text mesh pro

Open anandplay17 opened this issue 6 years ago • 3 comments

Unity poco Unable to get the text of a text field created using text mesh pro

image

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

anandplay17 avatar Feb 13 '19 10:02 anandplay17

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.

TreHack avatar Feb 14 '19 02:02 TreHack

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

4karion avatar Jul 15 '20 09:07 4karion

I've solved it by changing this line if (tmpText) return tmpText.text; to if (tmpText) return tmpText.GetParsedText();

4karion avatar Jul 15 '20 17:07 4karion