private static IPersistantRoutine GetPersistantRoutine(PersistantRoutineType type, MethodInfo toInvoke, params string[] _scenesToInvokeOn) { IPersistantRoutine toReturn = null; switch (type) { case PersistantRoutineType.OneShot: { if (_scenesToInvokeOn == null || _scenesToInvokeOn.Length == 0) { Debug.LogWarning("Cannot create a OneShot routine if no scene name is specified"); } else { OneShotPersistantRoutine routine = new OneShotPersistantRoutine(); routine.Initialize(_scenesToInvokeOn[0]); toReturn = routine; } } break; case PersistantRoutineType.BlindOneShot: { BlindOneShotPersistantRoutine routine = new BlindOneShotPersistantRoutine(); toReturn = routine; } break; default: { throw new System.NotImplementedException(); } } toReturn?.AssignRoutine(toInvoke); if (!toReturn.IsValid) { Debug.Log("Invalid PersistantRoutine. It will not invoke."); } return(toReturn); }