public override Statement generateStatementFromUI(GameObject commandContainer) { bool isMoveStatement = true; MoveStatement moveStatement = new MoveToJ(); foreach (Transform child in commandContainer.transform) { if (child.name.StartsWith("ToggleSuction")) { ToggleSuction toggleSuctionCommand = new ToggleSuction(); if (child.name.Contains("false")) { toggleSuctionCommand.isSuctionEnabled = false; } if (child.name.Contains("true")) { toggleSuctionCommand.isSuctionEnabled = true; } return(toggleSuctionCommand); isMoveStatement = false; } } if (isMoveStatement) { List <Toggle> toggles = new List <Toggle>(); commandContainer.GetComponentsInChildren <Toggle>(toggles); List <Transform> childTransforms = new List <Transform>(); commandContainer.GetComponentsInChildren <Transform>(childTransforms); foreach (Transform childTransform in childTransforms) { if (childTransform.name.Contains(movementTypeSelector.nameIdentifier())) { moveStatement = movementTypeSelector.getMoveStatementFromUI(childTransform.gameObject); } else if (childTransform.name.Contains(coordinateSelector.nameIdentifier())) { moveStatement.target = coordinateSelector.getCoordinateValues(childTransform.gameObject); } } } return(moveStatement); }