I’m trying to create a quiz game, exactly like how Jeopardy works. Right now, I’m attempting to make text objects from the top row each display a different item from a String, which lists all the categories, which if I can do that, it would help give an idea with the next step, getting text from a prefab to show a set question and answer based on which button the player chooses.
Tl Dr: Row (Parent Object) > Cells (Child Object), Text as either Child Object of Cells/direct child of Row
Text Object 1 – 6
—————>
String Item 1 – 6
Text 1 reads Item/Category 1, Text 2 reads Item/Category 2, etc
So far as practice, I’ve been able to make individual panels of the top row show a single number.
public class CategoryRow : MonoBehaviour {
public ClueCell[] cells { get; private set; }
public int Size => cells.Length;
public TextMeshProUGUI category_;
public Text Categories;
public void Awake() {
cells = GetComponentsInChildren<ClueCell>();
}
public void Start() {
int number = 1;
category_.text = "Category " + number.ToString();
Categories.text = "Category " + number.ToString();
}
}
But if I try to do something like this:
public class CategoryRow : MonoBehaviour
{
public ClueCell[] cells { get; private set; }
public int Size => cells.Length;
public TextMeshProUGUI category_;
public Text Categories;
public void Awake()
{
cells = GetComponentsInChildren<ClueCell>();
}
public void Start()
{
//int number = 1;
for(int x = 1; x < cells.Length; x++)
{
category_.text = "Category " + CategoryNum[x].ToString();
Categories.text = "Category " + CategoryNum[x].ToString();
}
}
}
It stops working. At this point, my brain is completely fried trying to look at other related posts and guides, and I feel like I’m missing something and getting lines of code, including what I’ve posted here, mixed up from so many different attempts. If there’s a way to do this without having to go, Text 1 = “”, Text 2 = “”, etc, I would very much like to know.
user26559224 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.