private IEnumerator InitSequence() { if (coroutineHandler == null) { coroutineHandler = Unity.Utils.CoroutinesHandler.Create(); } questionsLoader.RequestQuestions(OnSuccessQnALoad, OnFailQnALoad); while (!QnAIsLoaded) { yield return(null); } categoriesLoader.RequestCategoryDefinitions(OnSuccessDefinitionsLoad, OnFailDefinitionsLoad); while (!categoriesIsLoaded) { yield return(null); } IsInit = true; coroutineHandler.Dispose(); foreach (var bundle in questions.Values) { bundle.Shuffle(); } }
private void OnFailQnALoad(string error) { if (QnALoadAttemps < Settings.loadMaxAttempts) { Debug.LogFormat("QnA bundles failed to load with error {0}, attempting to load again in {1}", error, Settings.attemptDelayRemote.ToString()); coroutineHandler.StartCoroutine(DelayedAttempt(Settings.attemptDelayRemote, () => questionsLoader.RequestQuestions(OnSuccessQnALoad, OnFailQnALoad))); QnALoadAttemps++; } else if (fallbackQuestionsLoader != null && QnAFallbackLoadAttempts < Settings.fallbackLoadMaxAttempts) { Debug.LogFormat("QnA bundles failed to load with error {0}, attempting to load using fallback loader.", error); QnAFallbackLoadAttempts++; fallbackQuestionsLoader.RequestQuestions(OnSuccessQnALoad, OnFailDefinitionsLoad); } else { Debug.Log("Failed to load QnA Bundles, reset sequense initiated"); //init delayed reset sequense (invoke via event) //probably re load the app make sure to kill singletons //kill the coroutines //kill load attempts } }