MoveRelative() 공개 메소드

Move the scroll view by the specified amount.
public MoveRelative ( Vector3 relative ) : void
relative Vector3
리턴 void
예제 #1
0
    /// <summary>
    /// ScrollView变量初期化
    /// </summary>
    public void Clear()
    {
        isActived = false;

        _scrollView.DisableSpring();
        _scrollView.restrictWithinPanel = false;
        if (_scrollOrientation == ScrollOrientation.VERTICAL)
        {
            _scrollView.MoveRelative(new Vector3(0, _scrollView.panel.clipOffset.y, 0));
        }
        if (_scrollOrientation == ScrollOrientation.HORIZONTAL)
        {
            _scrollView.MoveRelative(new Vector3(_scrollView.panel.clipOffset.x, 0, 0));
        }

        for (int i = _itemsList.Count - 1; i >= 0; i--)
        {
            (this as ObjectPool <GameObject>).Store(_itemsList[i].gameObject);
        }

        _itemsList            = null;
        _lastPosition         = 0;
        _itemsToRecycleBefore = 0;

        onListMoved = null;

        _scrollView.restrictWithinPanel = true;
    }
예제 #2
0
 //向左翻页
 private void BtnleftVIP(GameObject go)
 {
     if (pageIndex.current != 1)
     {
         scrollView.MoveRelative(new Vector3(1000, 0, 0));
         centerOnChild.Recenter();
         pageIndex.InitPage(pageIndex.current, (int)VIPConsts.PAGEBOUNDARY_13);
     }
 }
예제 #3
0
    public void MoveNext(int delta)
    {
        Debug.Log("delta:" + delta);
        m_scrollView.DisableSpring();
        m_scrollView.MoveRelative(new Vector3(delta * cellWidth, 0));
        m_scrollView.InvalidateBounds();
        m_scrollView.RestrictWithinBounds(true);

        gameObject.SetActive(false);
        gameObject.SetActive(true);
    }
예제 #4
0
 void Update()
 {
     if (ScrollSceneManager.instance.isMoveToRight == false)
     {
         scrollView.MoveRelative(Vector3.right * Mathf.RoundToInt(speed * Time.deltaTime));
     }
     else if (ScrollSceneManager.instance.isMoveToRight == true)
     {
         scrollView.MoveRelative(Vector3.left * Mathf.RoundToInt(speed * Time.deltaTime));
     }
 }
    void UpdateValue(float momentum)
    {
        if (momentum > finalOffset)
        {
            scrollview.MoveRelative(new Vector3(0, finalOffset - lastValue, 0));
            LeanTween.cancel(gameObject);
            return;
        }

        scrollview.MoveRelative(new Vector3(0, momentum - lastValue, 0));
        lastValue = momentum;
    }
예제 #6
0
    void LoadItems(bool isLoadNext, float totalSpace, float itemSize)
    {
        int loadLineNum = Mathf.CeilToInt(totalSpace / itemSize);

        loadLineNum += preloadLineNum;
        if (loadLineNum > maxLineNum)
        {
            Debug.LogError("ScrollViewIncLoad, num of line to load is larger than max line.");
        }
        Debug.Log("ScrollViewIncLoad, load line num: " + loadLineNum + " totalSpace:" + totalSpace + " itemSize:" + itemSize);
        int loadNum = loadLineNum * maxPerLine;

        if (onAcquireItem != null)
        {
            if (isLoadNext)
            {
                int newEndIndex = endIndex + loadNum;
                while (newEndIndex > items.Count)
                {
                    items.Add(null);
                }
                for (; endIndex < newEndIndex; ++endIndex)
                {
                    //Debug.Log("ScrollViewIncLoad, acquire next index: " + endIndex);
                    GameObject item = onAcquireItem(endIndex, grid.transform);
                    if (item == null)
                    {
                        break;
                    }
                    items[endIndex] = item;
                }
            }
            else
            {
                int newStartIndex = startIndex - loadNum;
                newStartIndex = Mathf.Max(newStartIndex, 0);
                int realLoadLineNum = (startIndex - newStartIndex) / maxPerLine;
                for (; startIndex > newStartIndex; --startIndex)
                {
                    //Debug.Log("ScrollViewIncLoad, acquire prev index: " + (startIndex - 1));
                    GameObject item = onAcquireItem(startIndex - 1, grid.transform);
                    if (item == null)
                    {
                        break;
                    }
                    items[startIndex - 1] = item;
                }
                scroll.MoveRelative(isHorizontal ?
                                    new Vector3(realLoadLineNum * grid.cellWidth, 0, 0) :
                                    new Vector3(0, realLoadLineNum * grid.cellHeight, 0));
            }
        }
    }
예제 #7
0
 public void MoveScrollView(float height, float itemHeight)
 {
     if (height >= ui_scrollview_height)
     {
         ui_scrollview.MoveRelative(new Vector3(0, itemHeight, 0));
     }
 }
예제 #8
0
 private void LateUpdate()
 {
     //IL_00cd: Unknown result type (might be due to invalid IL or missing references)
     if (isUpdateTween && scroll != null && grid != null && tw != null && !isFinished)
     {
         if (tw.tweenFactor < 1f)
         {
             float tweenFactor = tw.tweenFactor;
             grid.cellHeight = (float)itemHeight * tweenFactor;
         }
         else
         {
             grid.cellHeight = (float)itemHeight;
             isFinished      = true;
             isUpdateTween   = false;
         }
         scroll.ResetPosition();
         scroll.MoveRelative(new Vector3(0f, grid.cellHeight * (float)selectIndex));
         grid.Reposition();
         if (isFinished)
         {
             ((UIRect)grid.GetComponent <UIWidget>()).SetAnchor(null);
         }
     }
 }
예제 #9
0
    public void MoveToLastVertical()
    {
        Vector3[] corners     = scroll.panel.worldCorners;
        Vector3   panelBottom = (corners[0] + corners[3]) * 0.5f;

        Transform panelTrans = scroll.panel.transform;

        Vector3 cp = panelTrans.InverseTransformPoint(grid.GetChildList()[0].transform.position);

        // UITable 中的条目根对象为 UISprite,居中对齐高度为 150,所以得到条目中心点在 Panel 中的坐标之后再加上其高度的一半,获得底端条目的底端坐标
        cp = new Vector3(cp.x, cp.y + 75, cp.z);
        Vector3 cc          = panelTrans.InverseTransformPoint(panelBottom);
        Vector3 localOffset = cp - cc;

        // Offset shouldn't occur if blocked
        if (!scroll.canMoveHorizontally)
        {
            localOffset.x = 0f;
        }
        if (!scroll.canMoveVertically)
        {
            localOffset.y = 0f;
        }
        localOffset.z = 0f;

        //        SpringPanel.Begin (scrollView.panel.cachedGameObject,
        //            panelTrans.localPosition - localOffset, 13);
        scroll.DisableSpring();
        scroll.MoveRelative(new Vector3(localOffset.x, -localOffset.y, localOffset.z));
    }
    private void AdjustOffset()    //if the widget list extends beyond the left margin, show last widget added to the scroll view
    {
        List <Transform> tempList = queGrid.GetChildList();
        int diff = tempList.Count - 8;

        scrollView.MoveRelative(new Vector3(diff * 80, 0, 0));
    }
예제 #11
0
 public override void OnDisable()
 {
     base.OnDisable();
     gameObject.SetActive(false);
     wrapContent.SortBasedOnScrollMovement();
     scrollView.MoveRelative(defScrollViewPos - transform.localPosition);
 }
 void Update()
 {
     if (_isPress)
     {
         scrollView.MoveRelative(direction * Speed);
         scrollView.RestrictWithinBounds(false, !verticle, verticle);
     }
 }
예제 #13
0
    public void MoveRelative(int delta)
    {
        m_scrollView.DisableSpring();
        if (m_scrollView.canMoveVertically)
        {
            m_scrollView.MoveRelative(new Vector3(0, (delta - m_lastDataIndex) * cellHeight));
        }
        else
        {
            m_scrollView.MoveRelative(new Vector3((m_lastDataIndex - delta) * cellWidth, 0));
        }
        m_scrollView.InvalidateBounds();
        m_scrollView.RestrictWithinBounds(true);

        gameObject.SetActive(false);
        gameObject.SetActive(true);
    }
예제 #14
0
    static int MoveRelative(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        UIScrollView obj  = (UIScrollView)LuaScriptMgr.GetUnityObjectSelf(L, 1, "UIScrollView");
        Vector3      arg0 = LuaScriptMgr.GetVector3(L, 2);

        obj.MoveRelative(arg0);
        return(0);
    }
예제 #15
0
    private static int MoveRelative(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        UIScrollView uIScrollView = (UIScrollView)LuaScriptMgr.GetUnityObjectSelf(L, 1, "UIScrollView");
        Vector3      vector       = LuaScriptMgr.GetVector3(L, 2);

        uIScrollView.MoveRelative(vector);
        return(0);
    }
예제 #16
0
    public void ItemViewPostion(int nItemNumber)
    {
        float width = mGridObject.cellWidth;
        //float height = mGridObject.cellHeight;

        Vector3 postionVec3 = VPostion(width, 0f, nItemNumber, 0);

        mScrollView.MoveRelative(postionVec3);
        mScrollView.RestrictWithinBounds(true);
    }
예제 #17
0
    void SetPanelClip(bool expand)
    {
        m_sprite_btn_chat_shrink.transform.localRotation = Quaternion.Euler(new Vector3(expand ? 180 : 0, 0, 0));
        int panelOffsetY = 52;

        m_sprite_Background.height = expand ? bgHeight + panelOffsetY : bgHeight;

        float offsetY = m_chatScrollview.panel.clipOffset.y + 1;

        if (offsetY < 0)
        {
            m_chatScrollview.MoveRelative(new Vector3(0, offsetY));//取反 往下相对移动
        }

        Vector4 clip = m_UIPanel.baseClipRegion;

        clip.w = m_sprite_Background.height; //size.y
        clip.z = m_sprite_Background.width;  //size.x

        Vector3 pos = m_chatScrollview.transform.parent.transform.localPosition;

        pos.y = clip.w * 0.5f;

        m_chatScrollview.transform.parent.transform.localPosition = pos;

        m_trans_chatItemRoot.localPosition = new Vector3(-clip.z * 0.5f + 5, clip.w * 0.5f - 5, 0);

        m_UIPanel.baseClipRegion = clip;
        m_UIPanel.clipOffset     = Vector2.zero;

        pos   = m_trans_PushContent.transform.localPosition;
        pos.y = m_sprite_Background.height;
        m_trans_PushContent.transform.localPosition = pos;

        UIWidget showWindowbtnWidget = m_btn_btn_ShowWindow.GetComponent <UIWidget>();

        if (showWindowbtnWidget != null)
        {
            showWindowbtnWidget.height = m_sprite_Background.height;
            showWindowbtnWidget.ResizeCollider();
        }
    }
예제 #18
0
    public void MoveRelative(int delta)
    {
        m_scrollView.DisableSpring();

        if (m_scrollView.canMoveVertically)
        {
            float maxHeight    = m_dataArrangeNum * cellHeight - m_panel.height;
            float targetHeight = Mathf.Min(maxHeight, (delta - m_lastDataIndex) * cellHeight);
            m_scrollView.MoveRelative(new Vector3(0, targetHeight));
        }
        else
        {
            float maxWidth    = m_panel.width - m_dataArrangeNum * cellWidth;
            float targetWidth = Mathf.Max(maxWidth, (m_lastDataIndex - delta) * cellWidth);
            m_scrollView.MoveRelative(new Vector3(targetWidth, 0));
        }

        gameObject.SetActive(false);
        gameObject.SetActive(true);
    }
예제 #19
0
        void ScrollToTab(int index)
        {
            if (!_tabScrollView.enabled || _renderWidth <= 0.0f || _tabCache.size <= 0)
            {
                return;
            }

            if (index >= tabPanelSize)
            {
                _tabScrollView.MoveRelative(new Vector3(GetTabHorizontalPositionByIndex(index), 0.0f, 0.0f));
            }
        }
예제 #20
0
        public static void ScrollHorizontalTo(this UIScrollView scroll, Transform t, bool centered = true)
        {
            scroll.ResetPosition();
            Vector3 delta      = t.TransformSpace(Vector3.zero, scroll.transform);
            Bounds  cellBounds = NGUIMath.CalculateRelativeWidgetBounds(t);
            float   x          = -delta.x + cellBounds.extents.x;

            if (centered)
            {
                x -= scroll.panel.GetViewSize().x / 2;
            }
            scroll.MoveRelative(new Vector3(x, 0, 0));
            scroll.RestrictWithinBounds(true);
        }
예제 #21
0
 static public int MoveRelative(IntPtr l)
 {
     try {
         UIScrollView        self = (UIScrollView)checkSelf(l);
         UnityEngine.Vector3 a1;
         checkType(l, 2, out a1);
         self.MoveRelative(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #22
0
        public static void ScrollCenter(this UIScrollView scroll, Transform target)
        {
            if (scroll != null && scroll.panel != null)
            {
                Vector3[] corners     = scroll.panel.worldCorners;
                Vector3   panelCenter = (corners[2] + corners[0]) * 0.5f;
                if (target != null && scroll != null && scroll.panel != null)
                {
                    Transform panelTrans = scroll.panel.cachedTransform;

                    // Figure out the difference between the chosen child and the panel's center in local coordinates
                    Vector3 cp          = panelTrans.InverseTransformPoint(target.position);
                    Vector3 cc          = panelTrans.InverseTransformPoint(panelCenter);
                    Vector3 localOffset = cp - cc;

                    // Offset shouldn't occur if blocked
                    if (!scroll.canMoveHorizontally)
                    {
                        localOffset.x = 0f;
                    }
                    if (!scroll.canMoveVertically)
                    {
                        localOffset.y = 0f;
                    }
                    localOffset.z = 0f;

                    // Spring the panel to this calculated position
                                        #if UNITY_EDITOR
                    if (!Application.isPlaying)
                    {
                        panelTrans.localPosition = panelTrans.localPosition - localOffset;

                        Vector4 co = scroll.panel.clipOffset;
                        co.x += localOffset.x;
                        co.y += localOffset.y;
                        scroll.panel.clipOffset = co;
                    }
                    else
                                        #endif
                    {
                        Vector3 offset = -localOffset;
                        offset.z = 0;
                        scroll.MoveRelative(offset);
                        //					SpringPanel.Begin(scroll.panel.cachedGameObject,
                        //						panelTrans.localPosition - localOffset, springStrength).onFinished = onFinished;
                    }
                }
            }
        }
예제 #23
0
 static int MoveRelative(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UIScrollView        obj  = (UIScrollView)ToLua.CheckObject <UIScrollView>(L, 1);
         UnityEngine.Vector3 arg0 = ToLua.ToVector3(L, 2);
         obj.MoveRelative(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #24
0
    private static int MoveRelative(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 2);
            UIScrollView uIScrollView = (UIScrollView)ToLua.CheckObject(L, 1, typeof(UIScrollView));
            Vector3      relative     = ToLua.ToVector3(L, 2);
            uIScrollView.MoveRelative(relative);
            result = 0;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
예제 #25
0
    private void updateTabButtonView()
    {
        NoticeTopButton selectBtn  = tabButtons [defaultSelectSid] as NoticeTopButton;
        UIGrid          grid       = content.GetComponent <UIGrid> ();
        UIScrollView    scrollView = topButtons.transform.GetComponent <UIScrollView> ();
        float           toX        = selectBtn.local_x;
        float           min_X      = grid.cellWidth * tabButtons.Keys.Count;

        Vector4 clip = scrollView.panel.finalClipRegion;

        if (min_X - toX < clip.z)
        {
            toX = min_X - clip.z + scrollView.panel.clipSoftness.x;
        }
        scrollView.MoveRelative(new Vector3(-toX, 0, 0));
        showDetail(selectBtn);
        topButtons.transform.localPosition             = Vector3.zero;
        topButtons.GetComponent <UIPanel>().clipOffset = Vector2.zero;
    }
예제 #26
0
    public static int MoveRelative(IntPtr l)
    {
        int result;

        try
        {
            UIScrollView uIScrollView = (UIScrollView)LuaObject.checkSelf(l);
            Vector3      relative;
            LuaObject.checkType(l, 2, out relative);
            uIScrollView.MoveRelative(relative);
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
예제 #27
0
    /// <summary>
    /// Advance toward the target position.
    /// </summary>

    protected virtual void AdvanceTowardsPosition()
    {
        float delta = RealTime.deltaTime;

        bool    trigger = false;
        Vector3 before  = mTrans.localPosition;
        Vector3 after   = NGUIMath.SpringLerp(mTrans.localPosition, target, strength, delta);
        Vector3 offset  = after - before;

        if ((after - target).sqrMagnitude < 0.01f)
        {
            after   = target;
            enabled = false;
            trigger = true;
        }
        UIScrollViewSimple tempScrollViewSimple = mTrans.GetComponent <UIScrollViewSimple>();

        if (tempScrollViewSimple != null)
        {
            tempScrollViewSimple.MoveRelative(offset, true);
            tempScrollViewSimple.UpdateScrollbars(false);
        }
        else if (mDrag != null)
        {
            mDrag.MoveRelative(offset);
        }
        else
        {
            mTrans.localPosition = after;
            Vector2 cr = mPanel.clipOffset;
            cr.x -= offset.x;
            cr.y -= offset.y;
            mPanel.clipOffset = cr;
        }

        if (trigger && onFinished != null)
        {
            current = this;
            onFinished();
            current = null;
        }
    }
예제 #28
0
    private void updateTabButtonView()
    {
        DayTopButton selectBtn = tabButtons [defaultSelectSid] as DayTopButton;

        if (selectBtn == null)
        {
            selectBtn = tabButtons [1] as DayTopButton;
        }
        UIGrid       grid       = content.GetComponent <UIGrid> ();
        UIScrollView scrollView = topButtons.transform.GetComponent <UIScrollView> ();
        float        toX        = selectBtn.local_x;

        Vector4 clip = scrollView.panel.finalClipRegion;

        if (toX > clip.z)
        {
            toX = toX - clip.z + scrollView.panel.clipSoftness.x;
            scrollView.MoveRelative(new Vector3(-toX, 0, 0));
            topButtons.GetComponent <UIPanel>().clipOffset = new Vector2(toX, 0);
        }
        showDetail(selectBtn);
    }
예제 #29
0
        static int _m_MoveRelative(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                UIScrollView gen_to_be_invoked = (UIScrollView)translator.FastGetCSObj(L, 1);



                {
                    UnityEngine.Vector3 _relative; translator.Get(L, 2, out _relative);

                    gen_to_be_invoked.MoveRelative(_relative);



                    return(0);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }
예제 #30
0
    public void SetLine(int line)
    {
        line = Mathf.Clamp(line, 0, totalLineCount - 1);
        scrollView.DisableSpring();
        scrollView.ResetPosition();
        if (scrollView.movement == UIScrollView.Movement.Horizontal)
        {
            int offset = (int)(Mathf.Min(cellWidth * line, maxOffset));

            scrollView.MoveRelative(new Vector3(-offset, 0, 0));
        }
        else
        {
            int offset = (int)(Mathf.Min(cellHight * line, maxOffset));
            scrollView.MoveRelative(new Vector3(0, offset, 0));
        }
        RefreshView(true);
    }