public void UnloadTimelineResources() { m_referenceCounter--; if (m_referenceCounter > 0) { return; } switch (m_timelineResourcesLoadState) { case TimelineResourceLoadingState.None: break; case TimelineResourceLoadingState.Failed: break; default: throw new ArgumentOutOfRangeException(); case TimelineResourceLoadingState.Loading: case TimelineResourceLoadingState.Loaded: m_timelineAssetDictionary.Unload(); if (null != m_spawnEffect) { m_spawnEffect.Unload(); } if (null != m_deathEffect) { m_deathEffect.Unload(); } UnloadAdditionalResources(); m_timelineResourcesLoadState = TimelineResourceLoadingState.None; break; } }
public IEnumerator LoadTimelineResources() { m_referenceCounter++; switch (m_timelineResourcesLoadState) { case TimelineResourceLoadingState.Loaded: case TimelineResourceLoadingState.Failed: break; case TimelineResourceLoadingState.Loading: while (m_timelineResourcesLoadState == TimelineResourceLoadingState.Loading) { yield return(null); } break; default: throw new ArgumentOutOfRangeException(); case TimelineResourceLoadingState.None: { m_timelineResourcesLoadState = TimelineResourceLoadingState.Loading; List <IEnumerator> loadRoutines = ListPool <IEnumerator> .Get(4); try { m_timelineAssetDictionary.GatherLoadRoutines(loadRoutines); if (null != m_spawnEffect) { loadRoutines.Add(m_spawnEffect.Load()); } if (null != m_deathEffect) { loadRoutines.Add(m_deathEffect.Load()); } GatherAdditionalResourcesLoadingRoutines(loadRoutines); } catch (Exception ex) { Debug.LogException(ex); m_timelineResourcesLoadState = TimelineResourceLoadingState.Failed; } yield return(EnumeratorUtility.ParallelRecursiveImmediateSafeExecution(loadRoutines.ToArray())); ListPool <IEnumerator> .Release(loadRoutines); m_timelineResourcesLoadState = TimelineResourceLoadingState.Loaded; break; } } }