Пример #1
0
        public override void OnShow(object param)
        {
            base.OnShow(param);
            m_skip_btn.AddClickCallBack(BtnSkip);
            m_mask.AddClickCallBack(BtnMask);

            m_mask.AddDragStartCallBack(DragStart);
            m_mask.AddDragEndCallBack(DragEnd);
            m_mask.AddDragCallBack(Draging);
            if (param != null)
            {
                GuidMaskCommonData maskData = (GuidMaskCommonData)param;
                m_skip_btn.Visible = maskData.m_confGuid.isSkip;
                m_data             = new GuidUIData(maskData.hasEvent, maskData.m_operaType, maskData.m_TypeValue, maskData.eventPassType);
                InitMask(maskData.m_maskdata);
                InitArt(maskData.m_artPos, maskData.m_confGuid);
            }
            ///////////
            m_mask.RawImage.raycastTarget = (m_data.OperaType != GuidEnum.Guid_DragScene);
            if (m_data.OperaType == GuidEnum.Guid_DragScene)
            {
                EngineCoreEvents.InputEvent.OnSwipeBegin += OnSwipeBegin;
                EngineCoreEvents.InputEvent.OnSwipeEnd   += OnSwipeEnd;
            }
        }
Пример #2
0
        public static GuidMaskBoardData InitMask(List <GuidMaskData> maskDatas, RectTransform m_RectRoot, GuidUIData uiData)
        {
            Vector4[] circleCenter = new Vector4[4];
            float[]   circleRadius = new float[4];

            Vector4[] rectCenter  = new Vector4[4];
            float[]   rectWidth   = new float[4];
            float[]   rectHeigh   = new float[4];
            int       circleIndex = 0;
            int       rectIndex   = 0;

            for (int i = 0; i < maskDatas.Count; i++)
            {
                GuidMaskData maskData         = maskDatas[i];
                Vector2      localLeftBottom  = WordToLocalPos(m_RectRoot, maskData.leftBottom);
                Vector2      localLeftTop     = WordToLocalPos(m_RectRoot, maskData.leftTop);
                Vector2      localRightBottom = WordToLocalPos(m_RectRoot, maskData.rightBottom);
                Vector2      localRightTop    = WordToLocalPos(m_RectRoot, maskData.rightTop);

                float centerx = (localLeftBottom.x + localRightBottom.x) / 2f;
                float centery = (localLeftBottom.y + localRightTop.y) / 2f;

                Vector2 center = new Vector2(centerx, centery);
                //Vector2 center = WordToLocalPos(maskData.centerPos);
                float width = localRightBottom.x - localLeftBottom.x; //maskData.width;
                float heigh = localRightTop.y - localLeftBottom.y;    //maskData.heigh;

                if (maskData.maskType == GuidMaskType.Rect)
                {
                    rectCenter[rectIndex] = center;
                    rectWidth[rectIndex]  = width / 2f;
                    rectHeigh[rectIndex]  = heigh / 2f;
                    rectIndex++;
                    uiData.AddRectData(maskData);
                }
                else if (maskData.maskType == GuidMaskType.Circle)
                {
                    circleCenter[circleIndex] = center;
                    circleRadius[circleIndex] = Mathf.Max(width, heigh) / 2f;
                    circleIndex++;

                    GuidCircleData circleData = new GuidCircleData();
                    circleData.centerPos = new Vector2((maskData.leftBottom.x + maskData.rightBottom.x) / 2f, (maskData.leftBottom.y + maskData.rightTop.y) / 2f);
                    circleData.radius    = Mathf.Max(maskData.rightBottom.x - maskData.leftBottom.x, maskData.rightTop.y - maskData.leftBottom.y);
                    circleData.btnName   = maskData.btnName;
                    uiData.AddCircleData(circleData);
                }
            }
            GuidMaskBoardData board = new GuidMaskBoardData(circleCenter, circleRadius, rectCenter, rectWidth, rectHeigh);

            return(board);
        }