ofb/Assets/Scripts/DialogBoxes.cs
slevy14 3de471ecd7 added transition scene with basic tutorial AND PERSISTENT DATA
PLEASE launch game from the main menu scene, otherwise persistent data will not load correctly
2023-04-27 12:27:15 -07:00

31 lines
844 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using TMPro;
public class DialogBoxes : MonoBehaviour
{
[Header("Dialog Messages:")]
[SerializeField] string[] dialogMessages;
private TMP_Text textField;
private int messageCount = 0;
// Start is called before the first frame update
void Start()
{
textField = this.gameObject.GetComponent<TMP_Text>();
textField.text = dialogMessages[0];
}
void OnAdvanceDialog() {
messageCount += 1;
if (messageCount < dialogMessages.Length) {
textField.text = dialogMessages[messageCount];
} else { // no more dialog messages, advance the scene
GameObject.Find("SceneManager").GetComponent<SceneController>().NextScene();
}
}
}