Hi
I am trying to get the values from text fields in my scene, but not all of them.
I know how to get objects of type:
var drinks = GameObject.FindObjectsOfType<Text>();
but this gets every text field in my scene.
So I then tried to tag them all, and just get those items:
var drinks = GameObject.FindGameObjectsWithTag("drinktag");
But then i can’t work out how to get the information held within each of the text fields as this doesn’t work
foreach (GameObject drinkis in drinks)
{
string drinkValue = drinkis.Text;
i have also tried
foreach (var drinkis in drinks)
{
var drinkValue = drinkis.Text;
var nameofdrink = drinkis.name
I can get the name of the object but not the value
I really need the value and I am going round in circles trying to find it
I have tried to search for a solution but no luck so hoping someone here can help me
thanks
thank you
I looked at that but didn’t understand it or how it relates! I can now loop through all the gameobjects and get their names, using FindGameObjectsWithTag()
I just can’t get the value written to the text field. Any ideas?
thanks