I’m having some problems when I try to enable some text, i’m not quite sure how to fix my code either so if someone could help that would be great, thank you!
My code is
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class Dialog : MonoBehaviour
{
public TextMeshProUGUI textDisplay;
public string[] sentences;
private int index;
public float typingSpeed;
public GameObject continueButton;
public void Start()
{
StartCoroutine(Type());
}
public void Update()
{
if(textDisplay.text == sentences[index])
{
continueButton.SetActive(true);
Debug.Log("enabled!");
}
}
IEnumerator Type()
{
foreach(char letter in sentences[index].ToCharArray())
{
textDisplay.text += letter;
yield return new WaitForSeconds(typingSpeed);
}
}
public void NextSentence()
{
continueButton.SetActive(false);
if (index < sentences.Length - 1)
{
index++;
textDisplay.text = "";
StartCoroutine(Type());
}
else
{
textDisplay.text = "";
continueButton.SetActive(false); }
}
}
and im having problems with the
public void Update()
{
if(textDisplay.text == sentences[index])
{
continueButton.SetActive(true);
Debug.Log("enabled!");
}
part.
My inspector is setup like
Thank you all!