Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using TMPro;
- using UnityEngine.SceneManagement;
- public class DialogeManager : MonoBehaviour
- {
- public GameObject dialogePanel;
- public TextMeshProUGUI npcNameText;
- public TextMeshProUGUI dialogText;
- private List<string> conversation;
- private int convoIndex;
- void Update()
- {
- if (Input.GetKeyDown(KeyCode.Return))
- {
- Next();
- }
- if (Input.GetKeyDown(KeyCode.Delete))
- {
- StopDialog();
- }
- }
- private void Start()
- {
- dialogePanel.SetActive(false);
- }
- public void Start_Dialog(string _npcName, List<string> _convo)
- {
- npcNameText.text = _npcName;
- conversation = new List<string>(_convo);
- dialogePanel.SetActive(true);
- convoIndex = 0;
- ShowText();
- }
- public void StopDialog()
- {
- dialogePanel.SetActive(false);
- }
- private void ShowText()
- {
- dialogText.text = conversation[convoIndex];
- }
- public void Next()
- {
- if(convoIndex<conversation.Count-1)
- {
- convoIndex += 1;
- ShowText();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement