private InfiniteScrollerCurrentStateData RefreshBeforeBuild(InfiniteScrollerCurrentStateData cd) { // Debug.LogError("refreshbeforebuild"); // Debug.LogError(cd.debug()); if (_innited) { _objectPool.deactivateAll(); cd.maxkey = cd.minkey - 1; float plus = _spacing; //if (cd.minkey == 0 && direction == directions.Vertical) { // plus = 0-plus; //} cd.currentmax = cd.currentmin + swapvar(plus); } UpdateSize(); //breaknext = true; return(cd); }
private void fill() { if (!_rectTransform) { return; } // Debug.LogError(_data.length()); //Debug.LogError("----------------------------------------------------------------------"); float xoffset = _rectTransform.anchoredPosition.x; float yoffset = _rectTransform.anchoredPosition.y; // Debug.LogError("yoffset"+yoffset); float offset = yoffset; float totalvalue = _height + hiddenPadding; if (direction == directions.Horizontal) { offset = xoffset; totalvalue = _width; } InfiniteScrollerCurrentStateData ret = clearInvisibleAndGetData(offset, totalvalue); if (refreshOnNextTick) { ret = RefreshBeforeBuild(ret); refreshOnNextTick = false; } float currentmin = ret.currentmin; float currentmax = ret.currentmax; _minkey = ret.minkey; _maxkey = ret.maxkey; bool _minset = ret.minset; bool _maxset = ret.maxset; //testBreak("currentmin = " + currentmin + ", " + _minkey + " currentmax = " + currentmax + ", " + _maxkey); if (_lastMin != currentmin || _lastMax != currentmax) { // Debug.LogError("currentmin = " + currentmin + ", " + _minkey + " currentmax = " + currentmax + ", " + _maxkey); // testBreak("dus"); } _lastMin = currentmin; _lastMax = currentmax; // Debug.Log("------------------------------------------------------"); if (!_minset) { if (buildDirection == builddirections.Forwards) { currentmin = _startpos; } else { currentmin = 0 - totalvalue; // Debug.LogError("currentmin = "+currentmin + " startpos = "+_startpos); } _minset = true; } if (!_maxset) { if (buildDirection == builddirections.Forwards) { currentmax = _startpos; } else { currentmax = _startpos - totalvalue; } _maxset = true; } //Debug.LogError("minkey1 = " + currentmax + "maxkey = " + currentmin); //Debug.LogError("currentmin = " + currentmax + "currentmax = " + currentmin); build("down", currentmax, offset, totalvalue); //Debug.LogError("minkey2 = " + currentmax + "maxkey = " + currentmin); build("up", currentmin, offset, totalvalue); }
private InfiniteScrollerCurrentStateData clearInvisibleAndGetData(float offset, float totalvalue) { List <GameObject> removes = new List <GameObject>(); float currentmin = 0; float currentmax = 0; bool _minset = false; bool _maxset = false; foreach (GameObject go in _objectPool.getActive()) { RectTransform r = go.GetComponent <RectTransform>(); Vector2 p = r.anchoredPosition; IInfiniteScrollPrefab prefabInterface = go.GetInterface <IInfiniteScrollPrefab>(); float ppos = p.y; float sizedeltapos = r.sizeDelta.y; float anchor = r.anchoredPosition.y; if (direction == directions.Horizontal) { ppos = p.x; sizedeltapos = r.sizeDelta.x; } float abspos = ppos + offset; if (swapvar(abspos) > totalvalue) { removes.Add(go); } else if (swapvar(abspos + swapvar(sizedeltapos)) < 0 - GetPadding()) { removes.Add(go); } else { if (swapvar(ppos) < swapvar(currentmin) || _minset == false) { currentmin = ppos + swapvar(0 - _spacing); _minset = true; _minkey = Int32.Parse(go.name); } if (swapvar(ppos + swapvar(sizedeltapos)) > swapvar(currentmax) || _maxset == false) { currentmax = (ppos + swapvar(sizedeltapos)) + swapvar(_spacing); _maxkey = Int32.Parse(go.name); _maxset = true; } } } InfiniteScrollerCurrentStateData ret = new InfiniteScrollerCurrentStateData(); foreach (GameObject go in removes) { _objectPool.deactivate(go); } ret.maxkey = _maxkey; ret.minkey = _minkey; ret.currentmax = currentmax; ret.currentmin = currentmin; ret.minset = _minset; ret.maxset = _maxset; return(ret); }