示例#1
0
        /// <summary>
        /// 抓取移动执行
        /// </summary>
        /// <param name="handPosition"></param>
        public void OnExecute(Vector3 handPosition)
        {
            if (screenY == null)
            {
                screenY = handPosition.y;
            }

            //往上走
            if (handPosition.y - screenY > extentValue)
            {
                if (onDirectionY != null)
                {
                    onDirectionY.Invoke(1);

                    if (onDirectionY.GetPersistentEventCount() > 0 || eventCount > 0)
                    {
                        MOperateManager.GetUIOperate(handIndex).SetScroll();
                    }
                }
                //如果相减,大于某个值
                screenY = handPosition.y;
            }

            //往下走
            if (handPosition.y - screenY < -extentValue)
            {
                if (onDirectionY != null)
                {
                    onDirectionY.Invoke(-1);

                    if (onDirectionY.GetPersistentEventCount() > 0 || eventCount > 0)
                    {
                        //设置UI滚动
                        MOperateManager.GetUIOperate(handIndex).SetScroll();
                    }
                }

                screenY = handPosition.y;
            }

            if (screenX == null)
            {
                screenX = handPosition.x;
            }

            if (handPosition.x - screenX > extentValue)
            {
                if (onDirectionX != null)
                {
                    onDirectionX.Invoke(1);

                    if (onDirectionY.GetPersistentEventCount() > 0 || eventCount > 0)
                    {
                        MOperateManager.GetUIOperate(handIndex).SetScroll();
                    }
                }

                screenX = handPosition.x;
            }

            if (handPosition.x - screenX < -extentValue)
            {
                if (onDirectionX != null)
                {
                    onDirectionX.Invoke(-1);

                    if (onDirectionY.GetPersistentEventCount() > 0 || eventCount > 0)
                    {
                        MOperateManager.GetUIOperate(handIndex).SetScroll();
                    }
                }

                screenX = handPosition.x;
            }
        }