IEnumerator SelectAction(TimelineAvatar avatar) { var actionIsReady = false; var selectionState = SelectState.Action; currentAvatar = avatar.transform; while (!actionIsReady) { switch (selectionState) { case SelectState.Action: actionSelector.ShowSelection(avatar); while (!actionSelector.actionSelected) { yield return(null); } selectionState = SelectState.Target; break; case SelectState.Target: targetSelector.ShowTargets(avatar); while (!targetSelector.selectedTarget) { yield return(null); } selectionState = SelectState.Done; break; case SelectState.Path: //TODO: Make path function, Component and object break; case SelectState.Done: actionIsReady = true; break; default: break; } yield return(null); } currentAvatar = null; timelineObjects.Add(new TimelineObject(avatar, actionSelector.selectedAction, targetSelector.selectedTarget, currentTime)); }