Hello,
I have a string of values. Values ranging from 1-10.
How do I increment the value by one single tap. That is I will first press 1 and after a while it should increment to 2 and so on…
foreach (string s in videos.Keys) {
if (Input.GetKeyDown(s)) {
..
}
}
you question was a little hard to grasp. So here is my two cents.
//private string[] keys= {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
//or is it like this
private string[] keys= {"q", "w", "e", "r", "t", "y", "u", "i", "o", "p"};
private int lookingForKey = 0;
private bool keyWasPressed = false; //this is used to prevent the key from getting pressed multiple times
void Update()
{
if (Input.GetKeyDown(keys[lookingForKey]) && !keyWasPressed)
{
keyWasPressed = true;
//what are you trying to do after a key was pressed?
Debug.Log("The " + keys[lookingForKey] + " key was pressed");
StartCoroutine(ChangeLookingForKey());
}
}
IEnumerator ChangeLookingForKey()
{
yield return new WaitForSeconds(5);
print("wait complete");
keyWasPressed = false;
lookingForKey++; //you'll have a null ref when this reaches 10, but hey it's a start :)
}