public virtual void SetLayoutHorizontal()
 {
     mFixedWidth = m_ClipRect == null ? 1 : m_ClipRect.rect.width;
     m_Tracker.Clear();
     m_Tracker.Add(this, SelfRect, DrivenTransformProperties.SizeDeltaX);
     SelfRect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, mFixedWidth);
 }
Ejemplo n.º 2
0
    public void Show()
    {
        if (IsShowing)
        {
            return;
        }

        SelfRect.DOLocalMove(Vector3.zero, .25f).SetEase(Ease.OutExpo);
        IsShowing = true;
    }
Ejemplo n.º 3
0
    public void Hide()
    {
        if (!IsShowing)
        {
            return;
        }

        SelfRect.DOLocalMove(HiddenPosition, .25f).SetEase(Ease.InExpo);
        IsShowing = false;
    }
        public virtual void SetLayoutVertical()
        {
            m_Tracker.Add(this, SelfRect, DrivenTransformProperties.SizeDeltaY);
            float h = mLastRow == null ? -m_Space.y : mLastRow.y - mLastRow.height - m_Space.y;

            if (m_ClipRect != null)
            {
                h = Mathf.Min(h, -m_ClipRect.rect.height);
            }

            SelfRect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, -h);
        }
    private Rect CalcurateViewportRect(Camera camera)
    {
        var corners = new Vector3[4];

        SelfRect.GetWorldCorners(corners);

        var p1 = RectTransformUtility.WorldToScreenPoint(camera, corners[1]);
        var p3 = RectTransformUtility.WorldToScreenPoint(camera, corners[3]);

        var x      = p1.x - (Screen.width * 0.5f);
        var y      = p3.y - (Screen.height * 0.5f);
        var width  = p3.x - p1.x;
        var height = p1.y - p3.y;

        x      /= (Screen.width * 0.5f);
        width  /= (Screen.width * 0.5f);
        y      /= (Screen.height * 0.5f);
        height /= (Screen.height * 0.5f);

        var size   = camera.orthographicSize;
        var aspect = Screen.width / (float)Screen.height;

        x      *= size * aspect;
        width  *= size * aspect;
        y      *= size;
        height *= size;

        var rect = new Rect()
        {
            x      = x,
            width  = width,
            y      = y,
            height = height
        };

        return(rect);
    }