static int StopMovement(IntPtr L)
 {
     L.ChkArgsCount(1);
     UnityEngine.UI.ScrollRect obj = (UnityEngine.UI.ScrollRect)L.ChkUnityObjectSelf(1, "UnityEngine.UI.ScrollRect");
     obj.StopMovement();
     return(0);
 }
 static int StopMovement(IntPtr L)
 {
     LuaScriptMgr.CheckArgsCount(L, 1);
     UnityEngine.UI.ScrollRect obj = (UnityEngine.UI.ScrollRect)LuaScriptMgr.GetUnityObjectSelf(L, 1, "UnityEngine.UI.ScrollRect");
     obj.StopMovement();
     return(0);
 }
Exemple #3
0
        /// <summary>
        /// Scrolls immediately to a given object in the scrollview.
        ///
        /// <b>Important:</b>
        /// Unity UI's scrolling component and UI setup is complex and full of variations. Therefore this
        /// function may not always give the expected results. Simply try it. If it does not work, you may copy the
        /// implementation of this function into your own code and customize as needed.
        /// </summary>
        /// <param name="scrollRect">ScrollView that should perform the scrolling.</param>
        /// <param name="focusObject">Object to scroll to. Must be a child of scrollRect's content object.</param>
        /// <param name="keepX">If true, scrolling does not apply to X.</param>
        /// <param name="keepY">If true, scrolling does not apply to Y.</param>
        /// <seealso cref="https://stackoverflow.com/questions/30766020/how-to-scroll-to-a-specific-element-in-scrollrect-with-unity-ui"/>
        public static void scrollJumpTo(UnityEngine.UI.ScrollRect scrollRect, GameObject focusObject, bool keepX = false, bool keepY = false)
        {
            RectTransform contentPanel = scrollRect.content;
            RectTransform target       = focusObject.GetComponent <RectTransform>();

            Canvas.ForceUpdateCanvases();

            Vector2 result =
                (Vector2)scrollRect.transform.InverseTransformPoint(contentPanel.position)        //current scrollpos
                - (
                    (Vector2)scrollRect.transform.InverseTransformPoint((Vector2)target.position) //... pos of object
                    );

            result.x += (scrollRect.GetComponent <RectTransform>().rect.width / 2);  //try to scroll object into center
            result.y -= (scrollRect.GetComponent <RectTransform>().rect.height / 2); //try to scroll object into center
                                                                                     //Debug.Log("scrollRect.rect="+(scrollRect.GetComponent<RectTransform>().rect)+", result="+result);

            result.x = Mathf.Clamp(result.x, 0, contentPanel.rect.width);
            result.y = Mathf.Clamp(result.y, -contentPanel.rect.height, 0);

            if (keepX)
            {
                result.x = contentPanel.anchoredPosition.x;
            }
            if (keepY)
            {
                result.y = contentPanel.anchoredPosition.y;
            }

            //scrollRect.inertia = false;
            contentPanel.anchoredPosition = result;
            scrollRect.StopMovement(); //Important: Stop any flow that may come from inertia, because it will falsify the programmatic scrolling results here (as we want a hard but reliable jump to a fixed position)
            //Debug.Log("-> result=" + result +", c.ap="+ contentPanel.anchoredPosition+"c.rs="+contentPanel.rect.height);
        }
Exemple #4
0
        private void Close()
        {
            Vector2 position = containerParent.anchoredPosition;

            position.y = 0.0f;
            containerParent.anchoredPosition = position;
            craftBook.StopMovement();
        }
Exemple #5
0
 static public int StopMovement(IntPtr l)
 {
     try {
         UnityEngine.UI.ScrollRect self = (UnityEngine.UI.ScrollRect)checkSelf(l);
         self.StopMovement();
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static int QPYX_StopMovement_YXQP(IntPtr L_YXQP)
 {
     try
     {
         ToLua.CheckArgsCount(L_YXQP, 1);
         UnityEngine.UI.ScrollRect QPYX_obj_YXQP = (UnityEngine.UI.ScrollRect)ToLua.CheckObject <UnityEngine.UI.ScrollRect>(L_YXQP, 1);
         QPYX_obj_YXQP.StopMovement();
         return(0);
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
 static int StopMovement(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         UnityEngine.UI.ScrollRect obj = (UnityEngine.UI.ScrollRect)ToLua.CheckObject <UnityEngine.UI.ScrollRect>(L, 1);
         obj.StopMovement();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemple #8
0
 private void setNeedReturn(float pos)
 {
     scrollView.StopMovement();
     //   D.log(string.Format("========setNeedReturn pos={0}  ", pos));
     setPosTo(pos);
 }