- Home /
How can i make dynamic spaces for letters in quiz game?
I have a quiz game in unity, im trying to make a dynamic answer text box in unity so that when i press one of my letter buttons it fills out the blanks. I'm having an issue trying to create the blanks first of all so they match the answer, and making them fill in on button press. see example.. can anyone help?
Hi, if I understand right you would that if you click the A button all letters that are A will appear. Do you have a Text field for each letter or a single text for the word?
Answer by myzzie · Sep 01, 2018 at 03:49 PM
Store the letters twice, once with all the letters and another with empty letters, then compare the two. When you press A, check the complete list if it contains an A, get the indexe's and iterate over the other list and pass in the A's. Kind of a rough idea but hope it helped.
Answer by toddisarockstar · Sep 02, 2018 at 01:28 AM
here is an example of finding and replacing missing letters:
public string real = "monkeys eat bannannas";
public string show = "_onk_ys _at ba__a__as";
void Update(){
//push the missing letters on the keyboard
if(Input.inputString.Length==1){
string s = Input.inputString;
int i = real.Length;
while(i>0){i--;
if(real.Substring(i,1)==s){
string set = show.Substring(0,i)+s;
if(i<show.Length){set = set +show.Substring(i+1);}
show = set;}}}}