Ejemplo n.º 1
0
        private List <BoxStruct> ConstructBox(int startIndex, int endIndex)
        {
            box.Clear();
            startIndex = startIndex / 4;
            endIndex   = (endIndex - 3) / 4;
            BoxStruct boxStruct;
            int       preLine = 0;

            boxStruct = new BoxStruct();
            int line = GetCharLine(startIndex);

            preLine         = line;
            boxStruct.line  = line;
            boxStruct.start = startIndex;
            for (int i = startIndex; i <= endIndex; ++i)
            {
                line = GetCharLine(i);
                if (preLine != line)
                {
                    box.Add(boxStruct);
                    preLine         = line;
                    boxStruct.line  = line;
                    boxStruct.start = i;
                }
                else
                {
                    boxStruct.end = i;
                }
            }
            box.Add(boxStruct);
            return(box);
        }
Ejemplo n.º 2
0
        private void GetBounds(VertexHelper toFill, List <LinkTag> m_HrefInfos)
        {
            SetNativeSize();

            DrawLineRect.Clear();
            //处理超链接包围框

            foreach (var hrefInfo in m_HrefInfos)
            {
                hrefInfo.Boxes.Clear();
                if (hrefInfo.GetStartIndex() >= toFill.currentVertCount)
                {
                    continue;
                }
                var pos = verts[hrefInfo.GetStartIndex()].position;

                List <BoxStruct> box = ConstructBox(hrefInfo.GetStartIndex(), hrefInfo.GetEndIndex());

                for (int i = 0; i < box.Count; ++i)
                {
                    BoxStruct boxStruct = box[i];
                    Rect      rect      = new Rect();

                    int startVer = boxStruct.start * 4 + 3;
                    int endVert  = boxStruct.end * 4 + 1;
                    if (endVert > toFill.currentVertCount)
                    {
                        endVert = toFill.currentVertCount - 2;
                    }
                    if (startVer >= toFill.currentVertCount)
                    {
                        break;
                    }
                    if (m_SupportVertexCache)
                    {
                        UIVertexCache vertexCache = CacheManager.Instance.GetVertexCache(_parseOutputText.GetHashCode());
                        if (vertexCache != null)
                        {
                            List <UIVertex> vertexs = new List <UIVertex>();
                            vertStart3 = verts[startVer];
                            vertEnd1   = vertexs[endVert];
                        }
                    }
                    else
                    {
                        toFill.PopulateUIVertex(ref vertStart3, startVer);
                        toFill.PopulateUIVertex(ref vertEnd1, endVert);
                    }

                    rect.Set(vertStart3.position.x, vertStart3.position.y, Mathf.Abs(vertEnd1.position.x - vertStart3.position.x), m_Lines[boxStruct.line].height);
                    hrefInfo.Boxes.Add(rect);
                    DrawLineRect.Add(rect);
                }
            }
        }