Esempio n. 1
0
        public void Init()
        {
            if (this.isInited)
            {
                return;
            }
            if (this.scroll == null)
            {
                this.scroll = GetComponent <ScrollRect>();
            }
            this.scroll.onValueChanged.AddListener(OnScrolling);

            this.isHorizontal    = this.scroll.horizontal;
            this.scaleFactor     = this.scroll.content.localScale;
            this.gridConfig      = this.scroll.content.transform.GetComponent <GridLayoutGroup>();
            this.padding         = gridConfig.padding;
            this.cellSize        = gridConfig.cellSize;
            this.spacing         = gridConfig.spacing;
            this.numPerRowOrCol  = gridConfig.constraintCount;
            gridConfig.enabled   = false;
            this.contentRT       = this.scroll.content;
            this.viewRT          = this.scroll.viewport;
            this.cellAlign       = gridConfig.childAlignment == 0 ? CellAlign.LeftOrTop : CellAlign.Center;
            this.cellTotal       = 0;
            this.curVisibleRange = new VisibleRange()
            {
                from = 0, to = -1
            };
            this.newVisibleRange = new VisibleRange()
            {
                from = 0, to = -1
            };
            this.isInited = true;
        }
Esempio n. 2
0
 void LateUpdate()
 {
     if (this.isOnShowing)
     {
         return;
     }
     if (this.isNeedReload)
     {
         this.Reload();
     }
     if (this.isDirty)
     {
         this.newVisibleRange = this.CalcVisibleRange();
         if (this.newVisibleRange.to - this.newVisibleRange.from >= 0)
         {
             this.RefreshVisibleCell();
         }
         this.isDirty = false;
     }
 }