/// <summary> /// Start internal IEnumerator startups /// </summary> /// <param name="ies">IeStruct</param> /// <param name="doneCallback">callback when done</param> /// <returns>IEnumerator</returns> // ------------------------------------------------------------------------------------------------------- protected IEnumerator startIEnumeratorInternal(IeStruct ies, Action doneCallback) { yield return(ies.startup); if (ies.error != null) { string errorStr = ies.error(); if (string.IsNullOrEmpty(errorStr)) { ies.doneSuccess = true; } else { if (!this.m_ignoreError) { this.setError(errorStr); } else { ies.doneSuccess = true; } } } else { ies.doneSuccess = true; } doneCallback(); }
/// <summary> /// Start IEnumerator startups /// </summary> /// <param name="ba">BeforeAfter</param> /// <returns>IEnumerator</returns> // ------------------------------------------------------------------------------------------------------- public IEnumerator startIEnumerator(BeforeAfter ba) { yield return(null); // m_detectedNewStartupObject { if (ba == BeforeAfter.Before) { this.m_detectedNewStartupObjectBefore = false; } else { this.m_detectedNewStartupObjectAfter = false; } } // clear error { this.setError(""); } List <IeStruct> list = (ba == BeforeAfter.Before) ? this.m_iesListBefore : this.m_iesListAfter; int listCount = list.Count; int listIndex = 0; int workingCoCounter = 0; while (listIndex < listCount) { if (this.hasError()) { break; } // ------------- if (workingCoCounter < this.m_numberOfCo) { IeStruct ies = list[listIndex++]; if (!ies.doneSuccess) { workingCoCounter++; StartCoroutine(this.startIEnumeratorInternal(ies, () => { workingCoCounter--; })); } } yield return(null); } while (workingCoCounter > 0) { yield return(null); } }