Advertisement
Guest User

My Textbox

a guest
Jan 21st, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class ItemDialouge : MonoBehaviour
  6. {
  7. public GameObject TextBox;
  8.  
  9. public Text Dialouge;
  10.  
  11. public string[] ChatArray;
  12.  
  13. private int index;
  14.  
  15. private bool MyBool;
  16.  
  17. private PlayerMovement Simon;
  18.  
  19.  
  20.  
  21. private void OnTriggerEnter2D(Collider2D collision)
  22. {
  23. MyBool = true;
  24. Simon = collision.gameObject.GetComponent<PlayerMovement>();
  25. index = 0;
  26. Dialouge.text = ChatArray[index];
  27. }
  28.  
  29. private void OnTriggerExit2D(Collider2D collision)
  30. {
  31. MyBool = false;
  32. index = 0;
  33. }
  34.  
  35. void Start()
  36. {
  37. TextBox.SetActive(false);
  38. }
  39.  
  40. public void Update()
  41. {
  42. Dialouge.text = ChatArray[index];
  43. if(MyBool == true)
  44. {
  45. if (Input.GetKeyDown("e"))
  46. {
  47. Time.timeScale = 0;
  48. TextBox.SetActive(true);
  49. Simon.moveSpeed = 0;
  50. index = 0;
  51. Dialouge.text = ChatArray[index];
  52. }
  53. if (Input.GetKeyDown(KeyCode.Mouse0) || Input.GetKeyDown(KeyCode.Space))
  54. {
  55. index ++;
  56. Dialouge.text = ChatArray[index];
  57. }
  58. if (index >= ChatArray.Length)
  59. {
  60. Simon.moveSpeed = 5;
  61. index = 0;
  62. TextBox.SetActive(false);
  63. }
  64. }
  65.  
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement