- Home /
Problem with a Strings Class
I have an input field where if you type "Take cereal" the scene changes and then if you take "Take bowl" it changes again. I want to know how can I use multiple words. Like for example if the user type "Take cereal" or "(lower case )take cereal" or "Get cereal" it will change the same scene.
string[] commands = new string[] { "Take cereal", "Take bowl" }; int currentCommand = 0; public void OnSubmit() { { WordInput = nameField.text;
if (WordInput == commands[currentCommand])
{
currentScene = currentCommand;
background.current_image.sprite = background.stockimages[sceneElements[currentScene].background_image];
fruit.current_image.sprite = fruit.stockimages[sceneElements[currentScene].fruit_image];
currentCommand++;
}
else
print("does not work");
Use String.Equals or String.Compareto for this purpose.. if condition is true as your complexity of if condition change with respect to the scenes you want..
Your answer
Follow this Question
Related Questions
GUI set max amount of characters for Label 1 Answer
Generate Json from Class Type List 1 Answer
Convert String To Class 1 Answer
Adding from one script to another with a String Name 3 Answers