Hey guys, i’m making 2D game that will be dialogue at the beggining and i want to change scene when my dialogue end. but i dont know how to do that maybe this is a simple question but i’m pretty new in C#
CODE:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine.SceneManagement;
public class Dialogue : MonoBehaviour
{
public TextMeshProUGUI textDisplay;
[TextArea(3, 20)]
public string[] sentences;
private int index;
public float typingSpeed;
public GameObject continueButton;
private void Start()
{
StartCoroutine(Type());
}
private void Update()
{
if(textDisplay.text == sentences[index])
{
continueButton.SetActive(true);
}
if(WHAT SHOULD İ WOULD WRİTE HERE)
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
}
IEnumerator Type()
{
foreach(char letter in sentences[index].ToCharArray())
{
if (Input.GetKey(KeyCode.J))
{
textDisplay.text += letter;
}
else
{
textDisplay.text += letter;
yield return new WaitForSeconds(0.04f);
}
}
}
public void NextSentences()
{
continueButton.SetActive(false);
if(index< sentences.Length -1)
{
index++;
textDisplay.text = "";
StartCoroutine(Type());
}
else
{
textDisplay.text = "";
continueButton.SetActive(false);
}
}
}