public int Select() { if (menuStack.Count == 0) { return(0); } MenuScript temp = menuStack.Peek(); if (temp.OptionLength() == 0) { return(-1); } int i = temp.getIndexRef().SelectOption(); switch (i) { case 0: // subMenu is activated, turn not done yet temp.Deactivate(); menuStack.Push(temp.ToNextMenu().subMenu); menuStack.Peek().Activate(); break; case -1: BackMenu(); i = 0; break; default: //end is reached, no more submenus to traverse StopCoroutine(inputCoroutine); while (menuStack.Count > 0) { menuStack.Pop().Deactivate(); } break; } return(i); }