Instead of setting the text component to currentQuestion it turns blank. I used debug.log(QuestionText) to determine that it is receiving the question. So I know it has something to do with how I’m assigning it, but I am completely drawing a blank. (I apologize if the scripts look sloppy. I cut out all the stuff that has nothing to do with the text component situation)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TouchController : MonoBehaviour
{
[HideInInspector]
public string currentQuestion;
[HideInInspector]
public string currentAnswer;
[HideInInspector]
public string category;
private string QuestionText;
private string AnswerText;
public GameObject HistoryButton;
public GameObject MathButton;
public GameObject ScienceButton;
public GameObject PoliticsButton;
public GameObject QuestionCard;
public GameObject QuestionCardText;
public GameObject AnswerCard;
public GameObject AnswerCardText;
ListManager listManager;
// Start is called before the first frame update
void Start()
{
listManager = this.GetComponent();
clickProcessRunning = false;
currentQuestion = listManager.math_currentQuestion.mathQuestion;
QuestionCardText.GetComponent<Text>().text = QuestionText;
//AnswerCardText.GetComponent<Text>().text = AnswerText;
QuestionText = currentQuestion;
//AnswerText = currentAnswer;
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.Linq;
public class ListManager : MonoBehaviour
{
public Math_Category math;
private static List<Math_Category> math_notViewedQuestions;
[HideInInspector]
public Math_Category math_currentQuestion;
void Start()
{
if (math_notViewedQuestions == null || math_notViewedQuestions.Count == 0)
{
math_notViewedQuestions = math.ToList<Math_Category>();
}
}
public void Math_GetRandomQuestion()
{
int randomQuestionIndex = Random.Range(0, math_notViewedQuestions.Count);
math_currentQuestion = math_notViewedQuestions[randomQuestionIndex];
math_notViewedQuestions.RemoveAt(randomQuestionIndex);
}
}