Advertisement
Guest User

Untitled

a guest
May 24th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using TMPro;
  6. using UnityEngine.SceneManagement;
  7.  
  8. public class DialogeManager : MonoBehaviour
  9. {
  10. public GameObject dialogePanel;
  11. public TextMeshProUGUI npcNameText;
  12. public TextMeshProUGUI dialogText;
  13. private List<string> conversation;
  14. private int convoIndex;
  15.  
  16. void Update()
  17. {
  18. if (Input.GetKeyDown(KeyCode.Return))
  19. {
  20. Next();
  21. }
  22. if (Input.GetKeyDown(KeyCode.Delete))
  23. {
  24. StopDialog();
  25. }
  26. }
  27. private void Start()
  28. {
  29. dialogePanel.SetActive(false);
  30. }
  31.  
  32. public void Start_Dialog(string _npcName, List<string> _convo)
  33. {
  34. npcNameText.text = _npcName;
  35. conversation = new List<string>(_convo);
  36. dialogePanel.SetActive(true);
  37. convoIndex = 0;
  38. ShowText();
  39. }
  40.  
  41. public void StopDialog()
  42. {
  43. dialogePanel.SetActive(false);
  44. }
  45.  
  46. private void ShowText()
  47. {
  48. dialogText.text = conversation[convoIndex];
  49. }
  50.  
  51. public void Next()
  52. {
  53. if(convoIndex<conversation.Count-1)
  54. {
  55. convoIndex += 1;
  56. ShowText();
  57. }
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement