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;
- public class ArrowControlIntro : MonoBehaviour
- {
- public int selectedButton = 0;
- public Image[] buttonList;
- int iamaint = 0;
- public sdr_dialogueTest dialogue;
- void Update()
- {
- ArrowChecher();
- }
- void ArrowChecher()
- {
- if (Input.GetKeyDown(KeyCode.UpArrow))
- {
- MoveDown();
- }
- if (Input.GetKeyDown(KeyCode.DownArrow))
- {
- MoveUp();
- }
- if (Input.GetKeyDown(KeyCode.Space))
- {
- if (buttonList[0].color == Color.yellow)
- {
- if (iamaint != 1)
- {
- dialogue.TextBox2();
- iamaint = 1;
- }
- else
- {
- MoveDown();
- }
- }
- if (buttonList[1].color == Color.yellow)
- {
- dialogue.TextBox3();
- }
- if (buttonList[2].color == Color.yellow)
- {
- dialogue.TextBox4();
- }
- if (buttonList[3].color == Color.yellow)
- {
- dialogue.TextBox5();
- }
- if (buttonList[4].color == Color.yellow)
- {
- dialogue.TextBox6();
- }
- if (buttonList[5].color == Color.yellow)
- {
- dialogue.TextBox7();
- }
- if (buttonList[6].color == Color.yellow)
- {
- dialogue.TextBox8();
- }
- if (buttonList[7].color == Color.yellow)
- {
- dialogue.TextBox9();
- }
- }
- }
- void MoveUp()
- {
- buttonList[selectedButton].color = Color.white;
- selectedButton++;
- if (selectedButton >= buttonList.Length)
- {
- selectedButton = 0;
- }
- buttonList[selectedButton].color = Color.yellow;
- }
- void MoveDown()
- {
- buttonList[selectedButton].color = Color.white;
- selectedButton--;
- if (selectedButton < 0)
- {
- selectedButton = (buttonList.Length - 1);
- }
- buttonList[selectedButton].color = Color.yellow;
- }
- using System.Linq;
- public Image[] imageArray;
- // this converts your imageArray into a gameobject list
- private List<GameObject> buttonGameObjectList
- {
- get
- {
- return imageArray.ToList().Select(x => x.gameObject).ToList();
- }
- }
- void MoveUp()
- {
- var activeButtonObjects = buttonGameObjectList.Where(x => x.GetComponent<Button>().enabled == true);
- activeButtonObjects[selectedButton].GetComponent<Image>().color = Color.white;
- selectedButton++;
- if (selectedButton >= buttonList.Length)
- {
- selectedButton = 0;
- }
- activeButtonObjects[selectedButton].GetComponent<Image>().color = Color.yellow;
- }
- void MoveUp()
- {
- if(buttonList[selectedButton + 1].disabled != false) {
- buttonList[selectedButton].color = Color.white;
- selectedButton++;
- if (selectedButton >= buttonList.Length)
- {
- selectedButton = 0;
- }
- buttonList[selectedButton].color = Color.yellow;
- }
- }
- void MoveUp()
- {
- if(buttonList[selectedButton - 1].disabled != false) {
- buttonList[selectedButton].color = Color.white;
- selectedButton--;
- if (selectedButton >= buttonList.Length)
- {
- selectedButton = 0;
- }
- buttonList[selectedButton].color = Color.yellow;
- }
- }
Add Comment
Please, Sign In to add comment