Пример #1
0
 public void Spring()
 {
     touchTransform.TouchMotor.Refresh();
     touchTransform.Calculation_Position.x = SS_Mathf.NearlyValue(touchTransform.TouchObject.transform.localPosition.x, scrollGroup.GroupBox.x);
     touchTransform.Calculation_Position.y = SS_Mathf.NearlyValue(touchTransform.TouchObject.transform.localPosition.y, scrollGroup.GroupBox.y);
     isSpringBack = false;
 }
Пример #2
0
        void Update()
        {
            if (isVertical)
            {
                GroupPosition = ThisTransform.anchoredPosition3D.y;                                     //获取当前物体位置
                PointerId     = SS_Mathf.NearlyNumber(GroupPosition - GroupBox_multiple.y, GroupBox.y); //获取当前列表指针 (无法确定整数)
                groupList.x   = GroupList.y;                                                            //生成的列表长宽
                groupList.y   = GroupList.x;
            }
            else
            {
                GroupPosition = -ThisTransform.anchoredPosition3D.x;                                    //获取当前物体位置
                PointerId     = SS_Mathf.NearlyNumber(GroupPosition - GroupBox_multiple.x, GroupBox.x); //获取当前列表指针(无法确定整数)
                groupList     = GroupList;                                                              //生成的列表长宽
            }


            if (PointerId != LatePointerId)
            {
                Generate_List();       //指针变动时刷新
            }
            LatePointerId = PointerId; //ID指针刷新
        }
Пример #3
0
        private void Enter(List <int> Ids)//生成物体
        {
            for (int i = 0; i < Ids.Count; i++)
            {
                if (BoxCount < 1)
                {
                    return;                                                  //数量不能为0
                }
                Num = (Loop) ? SS_Mathf.Int_Loop(Ids[i], BoxCount) : Ids[i]; //换算成整数循环

                if (!(Loop || SS_Mathf.If_IntervalValue(Num, 0, BoxCount - 1)))
                {
                    continue;                                                            //跳过这次循环
                }
                GameObject BoxObject = objectPool.Get_Object();
                // print("工作对象池:" + objectPool.ObjectPool_Work.Count + " 闲置对象池:" + objectPool.ObjectPool_Idle.Count);


                IdPool.Add(Ids[i], BoxObject);

                if (BoxObject != null)
                {
                    Vector2 List2D = SS_Mathf.List1D_To_List2D(Ids[i], (int)groupList.y); //下标换算

                    Vector2 BoxPosition;                                                  //根据二维下标计算位置
                    BoxPosition.x = ((isVertical) ? List2D.y : List2D.x) * GroupBox.x + GroupGap.x + BoxSize_Half.x;
                    BoxPosition.y = ((isVertical) ? List2D.x : List2D.y) * -GroupBox.y - GroupGap.y - BoxSize_Half.y;


                    ((RectTransform)BoxObject.transform).sizeDelta        = new Vector2(BoxSize.x, BoxSize.y); //设置内容盒子高宽
                    ((RectTransform)BoxObject.transform).anchorMin        = new Vector2(0, 1);                 //设置锚点为中心点
                    ((RectTransform)BoxObject.transform).anchorMax        = new Vector2(0, 1);
                    ((RectTransform)BoxObject.transform).anchoredPosition = BoxPosition;                       //位置放置
                    BoxsId.Add(Ids[i]);                                                                        //Id存入列表
                }
            }
        }
Пример #4
0
        public void OnDrag(PointerEventData eventData)//拖拽事件
        {
            if (IgnoreMouse && eventData.pointerId < 0)
            {
                return;                                        //忽略鼠标
            }
            if (TouchPool.Count < TouchLimit.x || TouchPool.Count > TouchLimit.y)
            {
                return;                                 //触摸限制
            }
            TouchScreening();                           //稳定点筛选

            FirstToSecond = Touch_Second - Touch_First; //手势向量计算

            //===================================

            TouchCenterPointer = Touch_First + FirstToSecond * 0.5f;//手势中心点位置

            if (TouchCenterPointer_Last - TouchCenterPointer != Vector2.zero)
            {
                TouchDragAngle = SS_EulerAngleConversion.Get_Angle_In_Vector2(TouchCenterPointer_Last - TouchCenterPointer);
            }


            if (TouchAngleLimit.Count > 0)
            {
                for (int i = 0; i < TouchAngleLimit.Count; i++)
                {
                    if (SS_Mathf.If_IntervalAngle(TouchDragAngle, TouchAngleLimit[i].x, TouchAngleLimit[i].y))
                    {
                        break;
                    }

                    if (i == TouchAngleLimit.Count - 1)
                    {
                        DragAngleLimit = true;
                    }
                }
            }

            if (!DragAngleLimit)
            {
                //当前手势向量角度 = 角度计算类.角度转换正负无限数值转换为正360度角(角度计算类.获得两个二维向量的角度差(二维向量.上,当前手势的向量,轴方向翻转));
                TouchAngle = SS_EulerAngleConversion.Angle_PN_To_P360(SS_EulerAngleConversion.Get_Angle_In_Vector2Deviation(Vector2.up, FirstToSecond, false));

                //缩放后的大小
                if ((Zoom && !Mobile) || (Zoom && TouchPool.Count > 1))
                {
                    //缩放比例差值 = ((当前手势向量长度-上一次手势向量长度)/上一次手势向量长度)
                    TouchScale = ((FirstToSecond.magnitude - FirstToSecond_Last.magnitude) / FirstToSecond_Last.magnitude);

                    //缩放后的虚拟计算大小 += 缩放比例差值 * 当前虚拟大小;
                    Calculation_Scale += TouchScale * Calculation_Scale;

                    //缩放后的 触摸点到物体中心向量的存档 += 缩放比例差值 * 触摸点到物体中心向量的存档
                    if (Mobile)
                    {
                        Save_TouchCenterToTransform_Position += TouchScale * Save_TouchCenterToTransform_Position;
                    }
                }

                //移动后的虚拟计算位置 = 触摸中心点 + 触摸中心点到物体中心向量存档;
                if (Mobile)
                {
                    Calculation_Position = TouchCenterPointer + Save_TouchCenterToTransform_Position;
                }


                //旋转后的虚拟计算位置 = 角度计算类.获取_位置_环绕旋转(环绕物:虚拟计算位置,环绕中心点:当前触摸手势中心点,轴向:世界坐标.z轴 ,旋转角度:数学类.获取角度差(手势角度存档,当前手势角度));
                if (Mobile && Rotation)
                {
                    Calculation_Position = SS_EulerAngleConversion.Get_Vector3_RotateRound(Calculation_Position, TouchCenterPointer, Vector3.forward, Mathf.DeltaAngle(Save_TouchAngle, TouchAngle));
                }

                //物体旋转后的虚拟计算角度 = 手势角度与物体角度差存档 + 当前手势角度
                if (Rotation)
                {
                    Calculation_Angle = Save_TouchToTransform_Angle + TouchAngle;
                }
            }

            DragAngleLimit = false;

            //更新双指的向量值

            FirstToSecond_Last = FirstToSecond;

            TouchCenterPointer_Last = TouchCenterPointer;


            if (TouchMotor != null)
            {
                TouchMotor.TouchOnDrag(Calculation_Position, Calculation_Angle, Calculation_Scale);
            }
        }