Beispiel #1
0
 public void UpdateLayout(RecyclerAdapter.State state)
 {
     if (Orientation == LayoutOrientation.Horizontal)
     {
         m_ScrollRect.content.sizeDelta = new Vector2(state.childSize.width * state.childCount, state.childSize.height);
     }
     else
     {
         m_ScrollRect.content.sizeDelta = new Vector2(state.childSize.width, state.childSize.height * state.childCount);
     }
 }
Beispiel #2
0
        public int GetViewHoldersCapacity(RecyclerAdapter.State state)
        {
            if (state.childCount == 0)
            {
                return(0);
            }

            if (Orientation == LayoutOrientation.Vertical)
            {
                if (state.childSize.height == 0)
                {
                    return(0);
                }
                return(Mathf.RoundToInt(0.5f + m_ScrollRect.viewport.rect.height / state.childSize.height)); //TODO support multiple types
            }

            if (state.childSize.width == 0)
            {
                return(0);
            }
            return(Mathf.RoundToInt(0.5f + m_ScrollRect.viewport.rect.width / state.childSize.width)); //TODO support multiple types
        }