Пример #1
0
 public void OnDestroy()
 {
     if (this.onFinished != null)
     {
         this.onFinished = null;
     }
 }
        static internal int checkDelegate(IntPtr l, int p, out SpringPanel.OnFinished ua)
        {
            int op = extractFunction(l, p);

            if (LuaDLL.lua_isnil(l, p))
            {
                ua = null;
                return(op);
            }
            else if (LuaDLL.lua_isuserdata(l, p) == 1)
            {
                ua = (SpringPanel.OnFinished)checkObj(l, p);
                return(op);
            }
            LuaDelegate ld;

            checkType(l, -1, out ld);
            LuaDLL.lua_pop(l, 1);
            if (ld.d != null)
            {
                ua = (SpringPanel.OnFinished)ld.d;
                return(op);
            }

            l  = LuaState.get(l).L;
            ua = () =>
            {
                int error = pushTry(l);

                ld.pcall(0, error);
                LuaDLL.lua_settop(l, error - 1);
            };
            ld.d = ua;
            return(op);
        }
Пример #3
0
    static int set_onFinished(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UICenterOnChild        obj  = (UICenterOnChild)o;
            SpringPanel.OnFinished arg0 = null;
            LuaTypes funcType2          = LuaDLL.lua_type(L, 2);

            if (funcType2 != LuaTypes.LUA_TFUNCTION)
            {
                arg0 = (SpringPanel.OnFinished)ToLua.CheckObject(L, 2, typeof(SpringPanel.OnFinished));
            }
            else
            {
                LuaFunction func = ToLua.ToLuaFunction(L, 2);
                arg0 = DelegateFactory.CreateDelegate(typeof(SpringPanel.OnFinished), func) as SpringPanel.OnFinished;
            }

            obj.onFinished = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index onFinished on a nil value" : e.Message));
        }
    }
Пример #4
0
    //设置ScrollView偏移量,带动画 Horizontal时用负数,Vertical时用正数
    public void SetScrollOffsetWithAnimation(float offset, float strength = 8f, SpringPanel.OnFinished callBackFunc = null)
    {
        SpringPanel springPanel = null;

        mScrollViewMoving       = true;
        scrollAnimationCallBack = callBackFunc;

        switch (movement)
        {
        case Movement.Horizontal:
            springPanel = SpringPanel.Begin(scrollView.gameObject, new Vector2(offset, 0), strength);
            break;

        case Movement.Vertical:
            springPanel = SpringPanel.Begin(scrollView.gameObject, new Vector2(0, offset), strength);
            break;

        default:
            mScrollViewMoving = false;
            callBackFunc      = null;
            Debug.LogError("may be you should case a new type here");
            break;
        }

        springPanel.onFinished = ScrollAnimationCallBack;
    }
Пример #5
0
 public static Delegate SpringPanel_OnFinished(LuaFunction func)
 {
     SpringPanel.OnFinished d = () =>
     {
         func.Call();
     };
     return(d);
 }
Пример #6
0
 void OnFinishedSetFocus()
 {
     m_bLockChangeScrollBar = false;
     if (null != m_onFinished)
     {
         m_onFinished();
         m_onFinished = null;
     }
 }
Пример #7
0
    private void ScrollAnimationCallBack()
    {
        mScrollViewMoving = false;

        if (scrollAnimationCallBack != null)
        {
            scrollAnimationCallBack();
        }
        scrollAnimationCallBack = null;
    }
Пример #8
0
    public static Delegate SpringPanel_OnFinished(LuaFunction func)
    {
        if (func == null)
        {
            SpringPanel.OnFinished fn = delegate { };
            return(fn);
        }

        SpringPanel.OnFinished d = (new SpringPanel_OnFinished_Event(func)).Call;
        return(d);
    }
Пример #9
0
    // 현재 뷰를 해당 인덱스가 있는 곳으로 옮겨준다.
    public void SetFocus(int index, SpringPanel.OnFinished onFinished = null)
    {
        if (index >= OnGetItemCount())
        {
            return;
        }

        Vector3 movePos = new Vector3();
        Vector4 clip    = m_Panel.finalClipRegion;

        float contentsSize = GetContentsSize();
        float viewSize     = 0f;

        if (m_bHorizontal)
        {
            viewSize = clip.z;
            int   columnCount = index / m_rowCount;
            float targetPos   = m_InitBound + columnCount * m_TotalItemSize.x;
            float startPos    = m_InitBound + clip.z * 0.5f;
            float limitPos    = m_InitBound + GetContentsSize() - clip.z * 0.5f;
            targetPos = Mathf.Max(targetPos, startPos);
            targetPos = Mathf.Min(targetPos, limitPos);
            movePos.x = targetPos - clip.x;
        }
        else
        {
            viewSize = clip.w;
            int   rowCount  = index / m_columnCount;
            float targetPos = m_InitBound - rowCount * m_TotalItemSize.y;
            float startPos  = m_InitBound - clip.w * 0.5f;
            float limitPos  = m_InitBound - GetContentsSize() + clip.w * 0.5f;
            // Vertical에서 아이템이 아래로 붙던 문제 수정[blueasa / 2015-12-08]
            targetPos = Mathf.Max(targetPos, limitPos);
            targetPos = Mathf.Min(targetPos, startPos);

            movePos.y = targetPos - clip.y;
        }

        // 컨텐츠 사이즈가 패널 사이즈보다 작을 때, 포커싱 이동 안하도록 수정[blueasa / 2015-11-16]
        // if (contentsSize > viewSize)
        {
            m_bLockChangeScrollBar = true;
            SpringPanel springPanel = SpringPanel.Begin(m_Panel.cachedGameObject, m_Panel.cachedTransform.localPosition - movePos, 8.0f);
            if (null != springPanel)
            {
                m_onFinished           = onFinished;
                springPanel.onFinished = OnFinishedSetFocus;
                //springPanel.onFinished = onFinished;
            }
        }
    }
Пример #10
0
    /// <summary>
    /// Start the tweening process.
    /// </summary>

    static public SpringPanel Begin(GameObject go, Vector3 pos, float strength, SpringPanel.OnFinished onfinish = null)
    {
        SpringPanel sp = go.GetComponent <SpringPanel>();

        if (sp == null)
        {
            sp = go.AddComponent <SpringPanel>();
        }
        sp.target     = pos;
        sp.strength   = strength;
        sp.onFinished = onfinish;
        sp.enabled    = true;
        return(sp);
    }
Пример #11
0
    static int set_onFinished(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UICenterOnChild        obj  = (UICenterOnChild)o;
            SpringPanel.OnFinished arg0 = (SpringPanel.OnFinished)ToLua.CheckDelegate <SpringPanel.OnFinished>(L, 2);
            obj.onFinished = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index onFinished on a nil value"));
        }
    }
Пример #12
0
    static int get_onFinished(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UICenterOnChild        obj = (UICenterOnChild)o;
            SpringPanel.OnFinished ret = obj.onFinished;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index onFinished on a nil value"));
        }
    }
Пример #13
0
    static int get_onFinished(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            SpringPanel            obj = (SpringPanel)o;
            SpringPanel.OnFinished ret = obj.onFinished;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index onFinished on a nil value" : e.Message));
        }
    }
Пример #14
0
    private static int get_onFinished(IntPtr L)
    {
        object obj = null;
        int    result;

        try
        {
            obj = ToLua.ToObject(L, 1);
            SpringPanel            springPanel = (SpringPanel)obj;
            SpringPanel.OnFinished onFinished  = springPanel.onFinished;
            ToLua.Push(L, onFinished);
            result = 1;
        }
        catch (Exception ex)
        {
            result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index onFinished on a nil value");
        }
        return(result);
    }
Пример #15
0
    /// <summary>
    /// Restrict the scroll view's contents to be within the scroll view's bounds.
    /// </summary>

    public virtual bool RestrictWithinBounds(bool instant, bool horizontal, bool vertical, SpringPanel.OnFinished finish = null)
    {
        Bounds  b          = bounds;
        Vector3 constraint = mPanel.CalculateConstrainOffset(b.min, b.max);

        if (!horizontal)
        {
            constraint.x = 0f;
        }
        if (!vertical)
        {
            constraint.y = 0f;
        }

        if (constraint.sqrMagnitude > 0.1f)
        {
            if (!instant && dragEffect == DragEffect.MomentumAndSpring)
            {
                // Spring back into place
                Vector3 pos = mTrans.localPosition + constraint;
                pos.x = Mathf.Round(pos.x);
                pos.y = Mathf.Round(pos.y);
                SpringPanel.Begin(mPanel.gameObject, pos, 13f, finish).strength = 8f;
            }
            else
            {
                // Jump back into place
                MoveRelative(constraint);

                // Clear the momentum in the constrained direction
                if (Mathf.Abs(constraint.x) > 0.01f)
                {
                    mMomentum.x = 0;
                }
                if (Mathf.Abs(constraint.y) > 0.01f)
                {
                    mMomentum.y = 0;
                }
                if (Mathf.Abs(constraint.z) > 0.01f)
                {
                    mMomentum.z = 0;
                }
                mScroll = 0f;
            }
            return(true);
        }
        return(false);
    }