Hello everybody.
I have 10 UI Text elements which I want to store in either an array or a list but I have been working with this and searching information for the past two days and it’s driving me crazy… Please help.
So far I’ve tried so many different methods. Here are some them:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class InGameSetup : MonoBehaviour {
public GameObject[] letterArr;
void Start () {
letterArr = GameObject.FindGameObjectsWithTag ("Letter");
print (letterArr.Length);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class InGameSetup : MonoBehaviour {
public List<GameObject> letterList;
void Start () {
letterList = GameObject.FindGameObjectsWithTag ("Letter");
print (letterList.Count);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class InGameSetup : MonoBehaviour {
public List<GameObject> letterList;
void Start () {
foreach (GameObject obj in GameObject.FindGameObjectsWithTag("Plane"))
{
letterList.Add (obj.gameObject);
}
}
}
When i print out the length of the array or list I either recieve 0 or nothing…