Hello comm unity)
I got code, where I’m trying to get all children of an object to array, then get the children of a child objects in array to) But I’ve got problem with List<>. So here’s the code:
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Text.RegularExpressions;
using System.Collections.Generic;
public class SearchChildren : MonoBehaviour {
Text textFinder;
string countFinder;
string countTextFinder;
GameObject[] counter;
float sum;
float countFinderNumber;
List<string> textFinderArr = new List<string>();
public void countResults ()
{
counter = new GameObject[transform.childCount];
for (int i = 0; i < transform.childCount; i++)
{
counter *= transform.GetChild(i).gameObject;*
textFinderArr.Add(counter*.transform.FindChild(“Result”).GetComponent().text);*
countFinder = Regex.Match(textFinderArr*, @“\d+”).Value;*
countFinderNumber = float.Parse(countFinder);
sum += countFinderNumber;
}
Debug.Log(sum);
}
}
So, the problem is that textFinderArr.Add(counter_.transform.FindChild(“Result”).GetComponent().text); geets only 1 element, and I can not understand why. So please explain it to me, cause I’m kinnda feel dumb)_