I have a string “Hello World” which is displayed as white color in the game view.
Now if I press e, e in Hello World should be highlighted i.e. e will become black.
Firs of all how to check which key i have pressed. Second I have to check if e is pressed then change e color in Hello World.
I am using this script.
private string displayedStr, correctStr;
public GUIStyle stringStyle, stringStyle1;
void Start ()
{
displayedStr = "Hello World";
correctStr = "";
}
void Update ()
{
if(Input.anyKeyDown)
{
Debug.Log(Input.inputString);
for(int i=0; i<displayedStr.Length; i++)
{
if(Input.inputString.Contains(displayedStr*.ToString()))*
-
{*
-
Debug.Log("Correct");*
-
}*
-
else*
-
{*
-
Debug.Log("Wrong");*
-
}*
-
}*
-
}*
-
}*
-
void OnGUI()*
-
{*
-
GUI.Label(new Rect(300, 100, 100, 100), displayedStr, stringStyle);*
-
GUI.Label(new Rect(300, 100, 100, 100), correctStr, stringStyle1);*
-
}*
I know I am doing lot of things wrong here. For correctStr I should check if that letter exists then only display that letter, something like that.