Esempio n. 1
0
 protected virtual void Start()
 {
     this.calculateBoundsCb = new UITable.CalculateBounds(this._CalculateBoundsOnlyOneLevel);
     this.Init();
     this.sv = this.mPanel.GetComponent <UIScrollView>();
     this.Reposition();
     base.enabled = false;
 }
Esempio n. 2
0
    protected void RepositionVariableSize(List <Transform> children, UITable.CalculateBounds calculateBounds = null)
    {
        if (calculateBounds == null)
        {
            calculateBounds = new UITable.CalculateBounds(NGUIMath.CalculateRelativeWidgetBounds);
        }
        float num  = 0f;
        float num2 = 0f;
        int   num3 = (this.columns <= 0) ? 1 : (children.Count / this.columns + 1);
        int   num4 = (this.columns <= 0) ? children.Count : this.columns;

        Bounds[,] array = new Bounds[num3, num4];
        Bounds[] array2 = new Bounds[num4];
        Bounds[] array3 = new Bounds[num3];
        int      num5   = 0;
        int      num6   = 0;
        int      i      = 0;
        int      count  = children.Count;

        while (i < count)
        {
            Transform transform  = children[i];
            Bounds    bounds     = calculateBounds(transform, !this.hideInactive);
            Vector3   localScale = transform.localScale;
            bounds.min        = Vector3.Scale(bounds.min, localScale);
            bounds.max        = Vector3.Scale(bounds.max, localScale);
            array[num6, num5] = bounds;
            array2[num5].Encapsulate(bounds);
            array3[num6].Encapsulate(bounds);
            if (++num5 >= this.columns && this.columns > 0)
            {
                num5 = 0;
                num6++;
            }
            i++;
        }
        num5 = 0;
        num6 = 0;
        int j      = 0;
        int count2 = children.Count;

        while (j < count2)
        {
            Transform transform2    = children[j];
            Bounds    bounds2       = array[num6, num5];
            Bounds    bounds3       = array2[num5];
            Bounds    bounds4       = array3[num6];
            Vector3   localPosition = transform2.localPosition;
            localPosition.x  = num + bounds2.extents.x - bounds2.center.x;
            localPosition.x += bounds2.min.x - bounds3.min.x + this.padding.x;
            if (this.direction == UITable.Direction.Down)
            {
                localPosition.y  = -num2 - bounds2.extents.y - bounds2.center.y;
                localPosition.y += (bounds2.max.y - bounds2.min.y - bounds4.max.y + bounds4.min.y) * 0.5f - this.padding.y;
            }
            else
            {
                localPosition.y  = num2 + (bounds2.extents.y - bounds2.center.y);
                localPosition.y -= (bounds2.max.y - bounds2.min.y - bounds4.max.y + bounds4.min.y) * 0.5f - this.padding.y;
            }
            num += bounds3.max.x - bounds3.min.x + this.padding.x * 2f;
            transform2.localPosition = localPosition;
            if (++num5 >= this.columns && this.columns > 0)
            {
                num5 = 0;
                num6++;
                num   = 0f;
                num2 += bounds4.size.y + this.padding.y * 2f;
            }
            j++;
        }
    }