private IEnumerator cGetScrollElements() { yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); started = false; firstGUIcall = true; firstUpdate = true; scrollElements = new List <UIScrollElement>(); for (int i = 0; i < scrollRect.content.childCount; i++) { UIScrollElement element = scrollRect.content.GetChild(i).GetComponent <UIScrollElement>(); //element.isFadedIn = false; if (element != null) { // set the inside value to fit its first position print("INSIDE - element " + i + ", position " + element.transform.position); if (!IsInside(element.transform.position)) { if (element.elementType == UIScrollElement.ElementType.editorLevel) { Debug.Log("nicht inside " + element.gameObject.name); } // begin fading animations if object is actually outside but still set to inside //element.gameObject.SetActive(false); element.InstantFadeOut(); } else// if (element.elementType == UIScrollElement.ElementType.product) { element.gameObject.SetActive(true); element.FadeIn(); // element.FadeIn(); } // reference the element scrollElements.Add(element); } } //started = true; //StartCoroutine(cCorrectInsideSetting()); yield break; }
// correct the current state of an scrollelement, if it should be faded out(-> outside the inside area) and its not, fade it and vice versa private IEnumerator cCorrectInsideSetting() { yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); for (int i = 0; i < scrollElements.Count; i++) { UIScrollElement element = scrollElements[i]; //if (i == scrollElements.Count - 1 && element.transform.position.y >= lowInside) // dragUpPossible = false; //else if (i == 0 && element.transform.position.y <= upInside) // dragDownPossible = false; bool inside = IsInside(element.transform.position); //Debug.Log("inside? " + inside + " i " + i + " pos " + element.transform.position); if (inside && element.isFadedIn) { //// first product //if (i == 0 && !dragUp) //{ // dragDownPossible = true; // dragUpPossible = false; //} //// last product //else if (i == scrollElements.Count - 1 && dragUp) //{ // dragUpPossible = false; // dragDownPossible = true; //} } // element is not inside => perform checks if thats correct else if (!inside) { //// first product //if (i == 0 && dragUp && IsInside(scrollElements[scrollElements.Count - 1].transform.position)) //{ // dragDownPossible = true; // dragUpPossible = false; //} //// last product //else if (i == scrollElements.Count - 1 && !dragUp && IsInside(scrollElements[0].transform.position)) //{ // dragUpPossible = true; // dragDownPossible = false; //} // begin fading animations if object is actually outside but still set to inside if (element.isFadedIn) { element.FadeOut(); } else { //dragDownPossible = true; //dragUpPossible = true; } } // element is between the fade lines, and outside the inside area else if (CanFade(element.transform.position, element) && !element.isFadedIn) { // begin fading animations if object is actually inside but not set to inside element.gameObject.SetActive(true); element.FadeIn(); //// the first item is inside, which means we cant drag //if (i == 0) //{ // dragDownPossible = false; //} //else if (i == scrollElements.Count - 1 && scrollElements.Count > 2) //{ // dragUpPossible = false; //} } } yield break; }