/// <summary> /// Clears all children of the DataBinderList. For emergency or instant clearing only /// </summary> public void ForceClearInstant() { Binders.Clear(); for (int i = 0; i < transform.childCount; i++) { Destroy(transform.GetChild(i).gameObject); } }
//Instantly clears the list regardless of if it is an animated list or not private void ClearListInstant() { //clear the list for (int i = 0; i < Binders.Count; i++) { DestroyImmediate(Binders[i].gameObject); } Binders.Clear(); }
//Coroutine controlling the clearing of the list (animates if it is an animated list) private IEnumerator ClearListRoutine() { //if is animated, play the out animation with appropriate delay and wait time if (m_isAnimatedList) { if (m_databinderPrefabToGenerate.GetComponent <Animator>() == null) { Debug.LogError($"The prefab {m_databinderPrefabToGenerate.name} is missing an animator and you are trying to animate it"); yield break; } if (m_animationTriggerOut.HasValue()) { foreach (DataBinder binder in Binders) { Animator anim = binder.GetComponent <Animator>(); anim.SetTrigger(m_animationTriggerOut); if (m_delay != 0) { yield return(new WaitForSeconds(m_delay)); } } } yield return(new WaitForSeconds(m_wait)); } //clear the list for (int i = 0; i < Binders.Count; i++) { Destroy(Binders[i].gameObject); } Binders.Clear(); if (m_isAnimatedList) { yield return(null); } }