Hello,
I would like to get two TextMeshPro gameobjects contained in the same parent gameobject, I searched for solutions I found nothing conclusive.
If someone wants to help me, I thank.
here is the code :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class ShowFinalResult : MonoBehaviour
{
/////////////////// Private Section //////////////////
private GameObject Manager;
private GameObject PlayersManager;
//////////////// Player ///////////////////////////
[SerializeField]
private Transform playersContainer;
public GameObject PlayerPrefabs;
public GameObject[] PlayerInput;
void Start()
{
Manager = GameObject.Find("GameManager").gameObject;
PlayersManager = GameObject.Find("PlayersManager").gameObject;
for (int i = 0; i < Manager.GetComponent<GameManager>().PlayerNumber; i++){
GameObject tempListing = Instantiate(PlayerPrefabs, playersContainer);
}
PlayerInput = GameObject.FindGameObjectsWithTag("PlayerList");
int y = 0;
foreach (GameObject Player in PlayerInput)
{
Player.FindChild("NameText").GetComponent<TMP_Text>().text = "testname";
Player.FindChild("ResultText").GetComponent<TMP_Text>().text = "testreult";
}
}
}
and the error message : Assets\Scripts\ShowFinalResult.cs(31,20): error CS1061: âGameObjectâ does not contain a definition for âFindChildâ and no accessible extension method âFindChildâ accepting a first argument of type âGameObjectâ could be found (are you missing a using directive or an assembly reference?)