Hey, ive made an array for a dialogue system where its serialisable so i can write the text out in the inspector.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using TMPro;
[System.Serializable]
public class RdmDialogue : MonoBehaviour
{
public TextMeshProUGUI TextBox;
[TextArea(3, 10)]
public string[] Opt1 = new string[4];
public string[] Opt2 = new string[4];
public string[] Opt3 = new string[4];
public string[] Opt4 = new string[4];
public void Random()
{
int randomNum = Random.Range(1, 4);
if (randomNum == 1)
{
TextBox.text = Opt1[0]
}
if (randomNum == 2)
{
TextBox.text = Opt2[0]
}
}
//etc
}
when you press the button it runs Random() and will make the text for the first element of the array appear but i was wondering how i would code a next sentence button that would change the [0] int to +1 so that it types out the next element