Exemple #1
0
 protected void UpdateBounds()
 {
     this.m_ViewBounds    = new Bounds(this.viewRect.rect.center, this.viewRect.rect.size);
     this.m_ContentBounds = this.GetBounds();
     if (!(this.m_Content == null))
     {
         Vector3 size   = this.m_ContentBounds.size;
         Vector3 center = this.m_ContentBounds.center;
         Vector2 pivot  = this.m_Content.pivot;
         ScrollRect.AdjustBounds(ref this.m_ViewBounds, ref pivot, ref size, ref center);
         this.m_ContentBounds.size   = size;
         this.m_ContentBounds.center = center;
         if (this.movementType == ScrollRect.MovementType.Clamped)
         {
             Vector2 zero = Vector2.zero;
             if (this.m_ViewBounds.max.x > this.m_ContentBounds.max.x)
             {
                 zero.x = Math.Min(this.m_ViewBounds.min.x - this.m_ContentBounds.min.x, this.m_ViewBounds.max.x - this.m_ContentBounds.max.x);
             }
             else if (this.m_ViewBounds.min.x < this.m_ContentBounds.min.x)
             {
                 zero.x = Math.Max(this.m_ViewBounds.min.x - this.m_ContentBounds.min.x, this.m_ViewBounds.max.x - this.m_ContentBounds.max.x);
             }
             if (this.m_ViewBounds.min.y < this.m_ContentBounds.min.y)
             {
                 zero.y = Math.Max(this.m_ViewBounds.min.y - this.m_ContentBounds.min.y, this.m_ViewBounds.max.y - this.m_ContentBounds.max.y);
             }
             else if (this.m_ViewBounds.max.y > this.m_ContentBounds.max.y)
             {
                 zero.y = Math.Min(this.m_ViewBounds.min.y - this.m_ContentBounds.min.y, this.m_ViewBounds.max.y - this.m_ContentBounds.max.y);
             }
             if (zero.sqrMagnitude > 1.401298E-45f)
             {
                 center = this.m_Content.anchoredPosition + zero;
                 if (!this.m_Horizontal)
                 {
                     center.x = this.m_Content.anchoredPosition.x;
                 }
                 if (!this.m_Vertical)
                 {
                     center.y = this.m_Content.anchoredPosition.y;
                 }
                 ScrollRect.AdjustBounds(ref this.m_ViewBounds, ref pivot, ref size, ref center);
             }
         }
     }
 }
Exemple #2
0
 protected void UpdateBounds()
 {
     this.m_ViewBounds    = new Bounds(this.viewRect.rect.center, this.viewRect.rect.size);
     this.m_ContentBounds = this.GetBounds();
     if (!(this.m_Content == null))
     {
         Vector3 size   = this.m_ContentBounds.size;
         Vector3 center = this.m_ContentBounds.center;
         Vector2 pivot  = this.m_Content.pivot;
         ScrollRect.AdjustBounds(ref this.m_ViewBounds, ref pivot, ref size, ref center);
         this.m_ContentBounds.size   = size;
         this.m_ContentBounds.center = center;
         if (this.movementType == ScrollRect.MovementType.Clamped)
         {
             Vector3 zero = Vector3.zero;
             if (this.m_ViewBounds.max.x > this.m_ContentBounds.max.x)
             {
                 zero.x = Math.Min(this.m_ViewBounds.min.x - this.m_ContentBounds.min.x, this.m_ViewBounds.max.x - this.m_ContentBounds.max.x);
             }
             else if (this.m_ViewBounds.min.x < this.m_ContentBounds.min.x)
             {
                 zero.x = Math.Max(this.m_ViewBounds.min.x - this.m_ContentBounds.min.x, this.m_ViewBounds.max.x - this.m_ContentBounds.max.x);
             }
             if (this.m_ViewBounds.min.y < this.m_ContentBounds.min.y)
             {
                 zero.y = Math.Max(this.m_ViewBounds.min.y - this.m_ContentBounds.min.y, this.m_ViewBounds.max.y - this.m_ContentBounds.max.y);
             }
             else if (this.m_ViewBounds.max.y > this.m_ContentBounds.max.y)
             {
                 zero.y = Math.Min(this.m_ViewBounds.min.y - this.m_ContentBounds.min.y, this.m_ViewBounds.max.y - this.m_ContentBounds.max.y);
             }
             if (zero != Vector3.zero)
             {
                 this.m_Content.Translate(zero);
                 this.m_ContentBounds = this.GetBounds();
                 size   = this.m_ContentBounds.size;
                 center = this.m_ContentBounds.center;
                 pivot  = this.m_Content.pivot;
                 ScrollRect.AdjustBounds(ref this.m_ViewBounds, ref pivot, ref size, ref center);
                 this.m_ContentBounds.size   = size;
                 this.m_ContentBounds.center = center;
             }
         }
     }
 }