Guest User

Untitled

a guest
Nov 21st, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class ArrowControlIntro : MonoBehaviour
  7.  
  8. {
  9.  
  10.  
  11.  
  12. public int selectedButton = 0;
  13. public Image[] buttonList;
  14.  
  15. int iamaint = 0;
  16.  
  17. public sdr_dialogueTest dialogue;
  18.  
  19.  
  20. void Update()
  21. {
  22. ArrowChecher();
  23.  
  24.  
  25. }
  26.  
  27. void ArrowChecher()
  28. {
  29. if (Input.GetKeyDown(KeyCode.UpArrow))
  30. {
  31.  
  32. MoveDown();
  33. }
  34. if (Input.GetKeyDown(KeyCode.DownArrow))
  35. {
  36. MoveUp();
  37. }
  38. if (Input.GetKeyDown(KeyCode.Space))
  39. {
  40. if (buttonList[0].color == Color.yellow)
  41. {
  42.  
  43. if (iamaint != 1)
  44. {
  45. dialogue.TextBox2();
  46. iamaint = 1;
  47. }
  48. else
  49. {
  50. MoveDown();
  51. }
  52. }
  53.  
  54. if (buttonList[1].color == Color.yellow)
  55. {
  56. dialogue.TextBox3();
  57.  
  58. }
  59. if (buttonList[2].color == Color.yellow)
  60. {
  61. dialogue.TextBox4();
  62.  
  63.  
  64. }
  65. if (buttonList[3].color == Color.yellow)
  66. {
  67.  
  68. dialogue.TextBox5();
  69.  
  70. }
  71.  
  72. if (buttonList[4].color == Color.yellow)
  73. {
  74. dialogue.TextBox6();
  75.  
  76.  
  77. }
  78. if (buttonList[5].color == Color.yellow)
  79. {
  80.  
  81. dialogue.TextBox7();
  82.  
  83. }
  84. if (buttonList[6].color == Color.yellow)
  85. {
  86.  
  87. dialogue.TextBox8();
  88.  
  89. }
  90.  
  91. if (buttonList[7].color == Color.yellow)
  92. {
  93.  
  94. dialogue.TextBox9();
  95.  
  96. }
  97.  
  98.  
  99. }
  100. }
  101.  
  102.  
  103. void MoveUp()
  104. {
  105. buttonList[selectedButton].color = Color.white;
  106. selectedButton++;
  107. if (selectedButton >= buttonList.Length)
  108. {
  109. selectedButton = 0;
  110. }
  111.  
  112. buttonList[selectedButton].color = Color.yellow;
  113. }
  114.  
  115. void MoveDown()
  116. {
  117. buttonList[selectedButton].color = Color.white;
  118. selectedButton--;
  119. if (selectedButton < 0)
  120. {
  121. selectedButton = (buttonList.Length - 1);
  122. }
  123.  
  124. buttonList[selectedButton].color = Color.yellow;
  125. }
  126.  
  127. using System.Linq;
  128.  
  129. public Image[] imageArray;
  130.  
  131. // this converts your imageArray into a gameobject list
  132. private List<GameObject> buttonGameObjectList
  133. {
  134. get
  135. {
  136. return imageArray.ToList().Select(x => x.gameObject).ToList();
  137. }
  138. }
  139.  
  140. void MoveUp()
  141. {
  142. var activeButtonObjects = buttonGameObjectList.Where(x => x.GetComponent<Button>().enabled == true);
  143.  
  144.  
  145. activeButtonObjects[selectedButton].GetComponent<Image>().color = Color.white;
  146. selectedButton++;
  147. if (selectedButton >= buttonList.Length)
  148. {
  149. selectedButton = 0;
  150. }
  151.  
  152. activeButtonObjects[selectedButton].GetComponent<Image>().color = Color.yellow;
  153. }
  154.  
  155. void MoveUp()
  156. {
  157. if(buttonList[selectedButton + 1].disabled != false) {
  158. buttonList[selectedButton].color = Color.white;
  159. selectedButton++;
  160. if (selectedButton >= buttonList.Length)
  161. {
  162. selectedButton = 0;
  163. }
  164.  
  165. buttonList[selectedButton].color = Color.yellow;
  166. }
  167. }
  168.  
  169. void MoveUp()
  170. {
  171. if(buttonList[selectedButton - 1].disabled != false) {
  172. buttonList[selectedButton].color = Color.white;
  173. selectedButton--;
  174. if (selectedButton >= buttonList.Length)
  175. {
  176. selectedButton = 0;
  177. }
  178.  
  179. buttonList[selectedButton].color = Color.yellow;
  180. }
  181. }
Add Comment
Please, Sign In to add comment