I am creating a game which involves a chat room.
I want to store an array of strings which are basically dialogues from 2 characters.
Every time I press Space bar I want to print each dialogue separately one after another.
I feel like I am close but I cant figure out how to print induvial elements from the array, all I was able to do was print all elements at once which I don’t want.
Any help would be really great, thanks.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class DialogueManager : MonoBehaviour
{
public TextMeshProUGUI dialogueText;
[TextArea(3, 10)]
public string[] sentences;
protected void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
StartDialogue();
}
}
public void StartDialogue()
{
foreach (string sentence in sentences)
{
???????
}
}
}
