I have a long switch case set of functions in C# I’m wondering if I can access or maybe I should say trigger a specific case from a coroutine?
Something like:
IEnumerator CheckIfAsked(){
KITTmodesObject.KITT_isThinking = true;
yield return new WaitForSeconds (3.0f); // wait time
KITTmodesObject.KITT_isThinking = false;
Access Switch Statement named "HaveIaskedThisBefore"
}
My Switch statements are being called like this:
public void pressButtonForCommand(string command)
{
switch (command) {
case "HaveIaskedThisBefore":
// Do Stuff
}
break;
Not sure what the question is. Do you want to put a switch statement in your coroutine? Or call a method from a coroutine that has a switch statement? I don’t see a reason why you couldn’t do either. Are you running into issues?
Like this? Or am I missing something?
pressButtonForCommand("HaveIaskedThisBefore");
1 Like
Sorry @Brathnann I should have been more clear.
Basically I want to call the switch case named
case "HaveIaskedThatBefore":
From my Coroutine.
I’m just not sure how to properly access it.
I could just copy everything from the switch case and throw that into my coroutine but it seemed silly since the switch case has it all there already if I can just access it.
Thanks @HelloMeow,
I’ll try that, maybe it is that simple… 
@HelloMeow Thanks, yup, that’s exactly what it was… perfect.
It seems you don’t need a switch statement, just extract the case block into a function, and call that function instead.
Yeah I could have done it that way it just seemed a bit redundant to have the code twice when all I needed to do was access it. @HelloMeow had what I needed. 