- Home /
Question by
Danielcool20 · Nov 18, 2019 at 12:15 AM ·
switchswitch-caseswitch scenes
Switch statement problem
I want to activate one case at a time starting with case"take cereal" and up to case"Eat cereal". When the user enters anything before typing "Take cereal", it will not register. I want to know if there is any code that can help me with this.
public void OnSubmit() { WordInput = nameField.text;
switch (WordInput)
{
case "Take cereal":
background.current_image.sprite = background.stockimages[sceneElements[currentScene=0].background_image];
fruit.current_image.sprite = fruit.stockimages[sceneElements[currentScene=0].fruit_image];
break;
case "Take bowl":
background.current_image.sprite = background.stockimages[sceneElements[currentScene = 0].background_image];
fruit.current_image.sprite = fruit.stockimages[sceneElements[currentScene = 1].fruit_image];
break;
case "Pour Cereal":
background.current_image.sprite = background.stockimages[sceneElements[currentScene=0].background_image];
fruit.current_image.sprite = fruit.stockimages[sceneElements[currentScene=2].fruit_image];
break;
case "Eat Cereal":
background.current_image.sprite = background.stockimages[sceneElements[currentScene = 0].background_image];
fruit.current_image.sprite = fruit.stockimages[sceneElements[currentScene = 3].fruit_image];
break;
Comment
Answer by $$anonymous$$ · Nov 18, 2019 at 05:34 AM
you can take input from dropdown instead of inputfield. that way user can only choose from options given by you.