Ejemplo n.º 1
0
        private void InitMask(List <GuidMaskData> maskDatas)
        {
            GuidMaskBoardData board = GuidTools.InitMask(maskDatas, m_RectRoot, m_data);

            m_material.SetVectorArray("circleCenter", board.circleCenter);
            m_material.SetFloatArray("circleRadius", board.circleRadius);
            m_material.SetVectorArray("rectCenter", board.rectCenter);
            m_material.SetFloatArray("rectWidth", board.rectWidth);
            m_material.SetFloatArray("rectHeigh", board.rectHeigh);
        }
Ejemplo n.º 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);
        }