コード例 #1
0
 public void ClearCache()
 {
     if (this.useRowsCache)
     {
         while (this.rowsCache.Count > 0)
         {
             ScoreTableRowComponent component = this.rowsCache.Dequeue();
             Destroy(component.gameObject);
         }
     }
 }
コード例 #2
0
 public void InitRowsCache(int cacheSize, List <ScoreTableRowIndicator> rowIndicators)
 {
     for (int i = 0; i < cacheSize; i++)
     {
         ScoreTableRowComponent item = Instantiate <ScoreTableRowComponent>(this.rowPrefab);
         item.AddIndicators(rowIndicators);
         item.gameObject.SetActive(false);
         this.rowsCache.Enqueue(item);
     }
     this.rowIndicators = rowIndicators;
     this.useRowsCache  = true;
 }
コード例 #3
0
        public void UpdatePositions()
        {
            int num        = 0;
            int index      = 0;
            int childCount = base.transform.childCount;

            while (index < childCount)
            {
                RectTransform child = (RectTransform)base.transform.GetChild(index);
                if ((child != null) && !this.excluded.Contains(child))
                {
                    ScoreTableRowComponent component = child.GetComponent <ScoreTableRowComponent>();
                    if (component == null)
                    {
                        LayoutRebuilder.MarkLayoutForRebuild(child);
                    }
                    else if (component.Position != 0)
                    {
                        num++;
                        Vector2 anchoredPosition = child.anchoredPosition;
                        anchoredPosition.y     = -(component.Position * (this.rowHeight + this.rowSpacing));
                        child.anchoredPosition = anchoredPosition;
                    }
                }
                index++;
            }
            int num5 = 0;
            int num6 = 0;
            int num7 = base.transform.childCount;

            while (num6 < num7)
            {
                RectTransform          child     = (RectTransform)base.transform.GetChild(num6);
                ScoreTableRowComponent component = child.GetComponent <ScoreTableRowComponent>();
                if ((component != null) && (component.Position == 0))
                {
                    num5++;
                    Vector2 anchoredPosition = child.anchoredPosition;
                    anchoredPosition.y     = -(((num + num5) + 1) * (this.rowHeight + this.rowSpacing));
                    child.anchoredPosition = anchoredPosition;
                }
                num6++;
            }
            float height = ((num5 + num) * (this.rowHeight + this.rowSpacing)) + this.rowHeight;

            this.SetHeight(height);
        }
コード例 #4
0
        public ScoreTableRowComponent AddRow()
        {
            if (!this.useRowsCache || (this.rowsCache.Count == 0))
            {
                ScoreTableRowComponent component2 = Instantiate <ScoreTableRowComponent>(this.rowPrefab);
                component2.AddIndicators(this.rowIndicators);
                component2.transform.SetParent(base.transform, false);
                this.SetDirty();
                return(component2);
            }
            ScoreTableRowComponent component = this.rowsCache.Dequeue();

            component.gameObject.SetActive(true);
            component.transform.SetParent(base.transform, false);
            component.transform.localScale = Vector3.one;
            this.SetDirty();
            return(component);
        }
コード例 #5
0
 public void RemoveRow(ScoreTableRowComponent row)
 {
     if (!this.useRowsCache)
     {
         this.excluded.Add((RectTransform)row.transform);
         DestroyImmediate(row.gameObject);
         this.SetDirty();
     }
     else
     {
         this.rowsCache.Enqueue(row);
         foreach (ScoreTableRowIndicator indicator in row.indicators.Values)
         {
             EntityBehaviour component = indicator.GetComponent <EntityBehaviour>();
             if (component != null)
             {
                 component.DetachFromEntity();
             }
         }
         row.gameObject.SetActive(false);
         row.transform.SetParent(null, false);
         this.SetDirty();
     }
 }