using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class EnemyMoveScript : MonoBehaviour
{
public float speed = 2;
public TextMeshPro MathText;
private GameManager gm;
void Start()
{
gm = FindObjectOfType<GameManager>();
MathText = GetComponentInChildren<TextMeshPro>();
MathText.text = gm.CurrentQ();
}
void Update()
{
transform.position += Vector3.left * speed * Time.deltaTime;
}
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
public class GameManager : MonoBehaviour
{
public static List<(string question, string answer)> availQuest;
private string crntQ;
private string crntA;
public void InitializeQuestions()
{
availQuest = new List<(string, string)> {
("3 - 2", "1"), // Answer is 1
("2 x 4", "8"), // Answer is 8
("50 - 30", "20"), // Answer is 9.5
("0 x 0", "0"), // Answer is -16
("5 + 5 - 3", "7"), // Answer is 7
("10 x 5", "50"), // Answer is 72
("6(2) - 2", "10"), // Answer is 27
("5 + 5", "10"), // Answer is 10
("10 / 2", "5"), // Answer is 9
("2 + 2", "4") // Answer is 4
};
}
public void Randomize()
{
if (availQuest.Count > 0)
{
int rnd = Random.Range(0, availQuest.Count);
crntQ = availQuest[rnd].question;
crntA = availQuest[rnd].answer;
availQuest.RemoveAt(rnd);
}
}
public string CurrentQ()
{
return crntQ;
}
public string CurrentA()
{
return crntA;
}
I’m trying to display the questions in textmeshpro but its not displaying anything and returning null. I’m a complete beginner at this so I can’t see the error here